Closed Bug 1190150 Opened 9 years ago Closed 5 years ago

Investigate HeapSetInformation(HeapOptimizeResources) to decommit low-fragmentation heap (LFH) caches in Windows 8.1+

Categories

(Core :: Memory Allocator, defect)

Unspecified
Windows 8.1
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1553296

People

(Reporter: cpeterson, Unassigned)

Details

https://msdn.microsoft.com/en-us/library/windows/desktop/aa366705%28v=vs.85%29.aspx

HeapSetInformation function

HeapOptimizeResources parameter

Heaps in the process with a low-fragmentation heap (LFH) will have their caches optimized, and the memory will be decommitted if possible. This value was added in Windows 8.1.
Those functions are for HeapAlloc-allocated memory, and we don't use that in gecko. System libraries might, but I don't know how many of them do.
I see in crash reports that the Flash plugin uses LFH (because they appear to use the default system heap). Tweaking our plugin container's heap might be rude to third-party plugins or it might help find (their) bugs.
Andrew, is this bug interesting for e10s memory usage? Gecko uses jemalloc, but we still might benefit from decommitting the LFH caches of system libraries (and Flash) that use HeapAlloc.
Flags: needinfo?(continuation)
I have no idea, sorry.
Flags: needinfo?(continuation)
I think that we absolutely should be doing this when responding to a memory-pressure event.

The API that we use to query for free virtual memory for the purposes of generating the memory-pressure event returns the size based on uncommitted and unreserved pages. When that event fires, we should be making every effort to free up as many pages as possible.

I would propose that if we were to implement this, it should be done immediately after (not before) a CoFreeUnusedLibraries call: by first asking COM to free any unneeded DLLs, those DLLs will be freed (freeing up VM), but it would also free any heap memory claimed by those DLLs. Then we do the LFH heap cleanup.
(In reply to Mike Hommey [:glandium] from comment #1)
> Those functions are for HeapAlloc-allocated memory, and we don't use that in
> gecko. System libraries might, but I don't know how many of them do.

All system libraries would use the LFH for their heap.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.