Closed Bug 864202 Opened 12 years ago Closed 4 years ago

large memory leak downloading fonts

Categories

(Core :: Graphics: Text, defect)

defect
Not set
major

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: jtd, Unassigned)

References

()

Details

(Whiteboard: [MemShrink:P2])

Attachments

(2 files)

While working on a testcase to reproduce a crash in the downloadable font cache (bug 838105), I discovered that we have a rather large leak in our font downloading code. Steps to reproduce (OSX): 1. Download http://people.mozilla.org/~jdaggett/fontstresstest.zip 2. Unzip fontstresstest.zip into ~/Sites directory 3. Enable .htaccess usage a. Open /etc/apache2/users/<username>.conf b. Change "AllowOverride None" to "AllowOverride All" c. Restart Apache: sudo apachectl restart 4. Load via HTTP "fontstress.html" 5. Open Console.app and verify in apache logs that fonts are always pulled (shouldn't see 304 responses to font requests) 6. Run over a long period (e.g. all night) Result: when running the test with Nightly on Win7, after two days about:memory shows: 2535MB explicit -- 2435MB heap-unclassified I'm assuming the cause is in gfx somewhere but it might also be in CORS or related loader code.
Whiteboard: [MemShrink]
Whiteboard: [MemShrink]
Kimura-san, why doesn't this qualify as a MemShrink bug?
probably just a bugzilla midair
Whiteboard: [MemShrink]
Yeah, sorry for the confusion. (Bugzilla didn't warn the mid-air somehow...)
Running a quick test with a DMD build on OSX, it looks like we're leaking resources related to the font load. The stack below stands out in the attached report. I need to track down what object is not getting free'd here. Unreported: 7,052 blocks in stack trace record 1 of 1,929 28,884,992 bytes (28,884,992 requested / 0 slop) 27.71% of the heap (27.71% cumulative); 38.46% of unreported (38.46% cumulative) Allocated at replace_malloc[/builds/mozcentral/obj-dmd/memory/replace/dmd/libdmd.dylib +0x1E48] 0x100019e48 malloc_impl[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/libmozglue.dylib +0x1AA0] 0x100077aa0 zone_malloc[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/libmozglue.dylib +0x1389] 0x100077389 malloc_zone_malloc[/usr/lib/system/libsystem_c.dylib +0x2D153] 0x7fff8bf68153 malloc[/usr/lib/system/libsystem_c.dylib +0x2DBA7] 0x7fff8bf68ba7 moz_xmalloc[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/libmozalloc.dylib +0x1685] 0x1000f0685 NS_Alloc[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2AC75B5] 0x104bc75b5 nsMemoryImpl::Alloc(unsigned long)[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2AC7599] 0x104bc7599 nsSegmentedBuffer::AppendNewSegment()[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2A80940] 0x104b80940 nsStorageStream::Write(char const*, unsigned int, unsigned int*)[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2A81AAC] 0x104b81aac non-virtual thunk to nsStorageStream::Write(char const*, unsigned int, unsigned int*)[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2A81C6D] 0x104b81c6d nsCacheEntryDescriptor::nsOutputStreamWrapper::Write_Locked(char const*, unsigned int, unsigned int*)[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x212047] 0x102312047 nsCacheEntryDescriptor::nsOutputStreamWrapper::Write(char const*, unsigned int, unsigned int*)[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x211F47] 0x102311f47 nsInputStreamTeeWriteEvent::Run()[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2A70BB4] 0x104b70bb4 nsThread::ProcessNextEvent(bool, bool*)[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2AAEDA4] 0x104baeda4 NS_ProcessNextEvent(nsIThread*, bool)[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2A133FF] 0x104b133ff nsThread::ThreadFunc(void*)[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2AAD837] 0x104bad837 _pt_root[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/libnss3.dylib +0x21FB23] 0x10141fb23 _pthread_start[/usr/lib/system/libsystem_c.dylib +0x14742] 0x7fff8bf4f742 It also looks like a fair amount of memory is used by the CGFont associated with Mac font entries: Unreported: ~1,879 blocks from ~66 stack trace records in stack frame record 22 of 6,667 ~17,151,645 bytes (~15,492,354 requested / ~1,659,291 slop) 16.46% of the heap; 22.84% of unreported PC is MacOSFontEntry::GetFontRef()[/builds/mozcentral/obj-dmd/dist/NightlyDebug.app/Contents/MacOS/XUL +0x2C67CAA] 0x104d67caa
Looks like this is the cache's fault? John, how bad is this during normal usage?
Component: Graphics: Text → Networking: Cache
Whiteboard: [MemShrink] → [MemShrink:P2]
Flags: needinfo?(michal.novotny)
I've tried to run the test and I can see the increasing memory usage but the memory isn't used by the memory cache. nsStorageStream doesn't leak memory and we don't leak nsStorageStream in nsMemoryCacheDevice. BTW, almost all the allocated memory (ca 90%) is released when I close the tab with the test or when I click on "Minimize memory usage" button. Re-running the test again released the remaining 10% in my case.
Flags: needinfo?(michal.novotny)
Assignee: jd.bugzilla → nobody
michal is there still something to do here? should it be wfm? Given back to fonts?
Flags: needinfo?(michal.novotny)
Whiteboard: [MemShrink:P2] → [MemShrink:P2][necko-backlog]
I don't see leak or any other problem in the cache.
Component: Networking: Cache → Graphics: Text
Flags: needinfo?(michal.novotny)
Whiteboard: [MemShrink:P2][necko-backlog] → [MemShrink:P2]

I couldn't manage to reproduce this issue. Since the bug was logged 9 years ago, most likely isn't reproducible anymore for the reporter also.
Closing this bug as resolved: Worksforme.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: