Closed Bug 421439 Opened 16 years ago Closed 16 years ago

Thunderbird loses memory, grows and eventually hits memory ulimit

Categories

(MailNews Core :: Database, defect)

1.8 Branch
x86
FreeBSD
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: yuri, Assigned: Bienvenu)

References

(Depends on 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

User-Agent:       Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.12) Gecko/20080229 Firefox/2.0.0.12
Build Identifier: 2.0.0.12

My Thunerbird grows spontaneously over time to over 1GB and crahes after memory is exhausted.

I did memory profiling with gooogle-perftools and am attaching here the resultimg memory profile.

Seems like NSGetModule looses ~96.6% of the memory.

Please see profile attached. 

I use version 2.0.0.12 but the same memory loss was happening already for a long while.



Reproducible: Always

Steps to Reproduce:
1.
2.
3.
Comment on attachment 307866 [details]
profile converted to image showing the problem

inn the future, it might be a good idea to profile builds for which you have symbols....
Attachment #307866 - Attachment is obsolete: true
--enable-debugger-info-modules
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
FYI: I tried to configure with --enable-debugger-info-modules but all modules are still being stripped. So I had to manually remove strip commands from makefiles.
I would like to reopen this bug since I've ran new experiment with debugging info.

From the profile I see that all lost memory is being allocated from the line:
orkinHeap.cpp:187: void* block = ::operator new(inSize);
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
so, i don't know why you think we're "losing" memory. obviously crashing isn't a good idea, but w/o a stack trace, there's nothing we can do.

afaik we don't default to --enable-strip, so I'm assuming you have some other odd configure flags (please include your configure flags somewhere).

also note that investigating problems in a branch version of thunderbird is not very helpful. please use a trunk version.
Assignee: nobody → bienvenu
Component: General → MailNews: Database
Product: Thunderbird → Core
QA Contact: general → database
Summary: Thunderbird looses memory, grows and eventually crashes. → Thunderbird loses memory, grows and eventually crashes.
Version: unspecified → 1.8 Branch
> so, i don't know why you think we're "losing" memory. obviously crashing isn't
> a good idea, but w/o a stack trace, there's nothing we can do.

I think thunerbird is losing memory because profile shows this. And also when
I leave it alone it goes to 1.5GB and crashes. There is no need for mail client
to use 1.5GB.

Stack trace of what? Crash resulting in a memory loss can be triggered by
*any* malloc not necessarily the one losing memory. Also stack trace can be
inferred from the profile that I attached. All arrows mean function calls.

> afaik we don't default to --enable-strip, so I'm assuming you have some other
> odd configure flags (please include your configure flags somewhere).

The only configure flag I used (except for --prefix) is --enable-debugger-info-modules.
But I used FreeBSD-patched port version. This might have caused stripping.

I am rerunning with the trunk version and will post results here once I am done.
I've got build error (below) while compiling tru8nk from CVS.
====error log=====
cd FreeBSD7.0_OPT.OBJ ; sh /yuri-huge/thunderbird/mozilla/security/nss/cmd/shlibsign/./sign.sh /yuri-huge/thunderbird/mozilla/dist \
        /yuri-huge/thunderbird/mozilla/security/nss/cmd/shlibsign/FreeBSD7.0_OPT.OBJ FreeBSD \
        /yuri-huge/thunderbird/mozilla/dist/lib /yuri-huge/thunderbird/mozilla/dist/lib/libsoftokn3.so
/yuri-huge/thunderbird/mozilla/security/nss/cmd/shlibsign/FreeBSD7.0_OPT.OBJ/shlibsign -v -i /yuri-huge/thunderbird/mozilla/dist/lib/libsoftokn3.so
Fatal error 'Spinlock called when not threaded.' at line 78 in file /usr/src/lib/libthr/thread/thr_spinlock.c (errno = 2)
Abort trap
sounds like the freebsd ports people have some random patches that they haven't sent us, can you please figure out which they are and file bugs to integrate them?

"memory loss" is something one would find w/ profiling tools (which we document on our developer sites). btw, profiles as pictures are not truly appreciated. and please don't expect us to regenerate stack traces from pictures, that's not our jobs. as for crashes, i want a stack trace from mdb or gdb or whatever showing a crash.
Ok, I will submit FreeBSD patches as a separate PR.

> "memory loss" is something one would find w/ profiling tools 

That's what I am doing.
> btw, profiles as pictures are not truly appreciated.
What kind of profiles do you truly appreciate? perftools profile can only be viewed as picture that I've attached.

When I talk about the crash here I mean that OS kills thunderbird as a runaway process. Because on my system 1.5GB is a limit for the process. So stacktrace wouldn't be of any significance.

This picture shows who called the allocator when lost memory was allocated.
Please let me know what information is missing so I can obtain it and attach it here.
well um. typically when you use ulimit (or an equivalent), a call to malloc() will return 0, and our code either handles it (good) or fails to handle it (crash). If you crash because we dereferenced a null pointer, then i want a stack trace. if your kernel is evil like the linux kernel in its default configuration and kill()s our process. Then I can't handle the memory case.

We can try to use heuristics to determine maximum memory load, but that's a bit of a mess. And I'd rather not go there. How big is your mailbox? AFAIK the current codebase tries to maintain a complete in memory reference of a mail folder's index. This is of course not the best approach for a folder with >1million messages, but oh well.
Summary: Thunderbird loses memory, grows and eventually crashes. → Thunderbird loses memory, grows and eventually hits memory ulimit
> well um. typically when you use ulimit (or an equivalent), a call to malloc()
> will return 0, and our code either handles it (good) or fails to handle it

See, this is essentially a different issue how ulimit-style limitation is handled. I am not sure but I think depending on circumstances either malloc returns 0 (as a result of failure to the call to brk-like syscall) or OS will send a signal.

But the main issue in this PR is why memory grows so much.

> How big is your mailbox?

My 'Sent' file on disk is gigantic: ~1GB (with about 5k messages)
My 'Inbox' on disk is ~317MB (with about 5k messages)
These are the biggest two.

So does thunderbird try to load them in memory? This might be the cause of a problem.

(In reply to comment #13)

> My 'Sent' file on disk is gigantic: ~1GB (with about 5k messages)
> My 'Inbox' on disk is ~317MB (with about 5k messages)
> These are the biggest two.
> 
> So does thunderbird try to load them in memory? This might be the cause of a
> problem.

We're not /that/ stupid. However, the mork code loads the entire msf file (Inbox.msf, Sent.msf) into memory.

It looks like everything is merely a mork problem. I am currently working on ridding mailnews of mork (see bug 11050 for more details); if all goes well, trunk should be rid of it by the end of this summer.
Depends on: 11050
Product: Core → MailNews Core
Problem doesn't exist for me in 2.0.0.17.
Since I seem to be the only one who have experienced it I am closing it.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago16 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: