Closed Bug 730447 Opened 8 years ago Closed 8 years ago

GC: Create a real counter for malloc bytes

Categories

(Core :: JavaScript Engine, defect)

defect
Not set

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: billm, Assigned: billm)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Attached patch patchSplinter Review
This is work toward bug 681479.

Right now we do a GC whenever 100MB of malloc memory has been allocated. This patch tries to improve this heuristic. It keeps a count of how many malloc bytes are allocated at any time. This requires that callers of free know how many bytes are being freed. It seems like in all the important cases, we know this. Once we know how many malloc bytes there are, we can use the usual heuristic of GCing when malloc bytes reach lastMallocBytes*3.

The big advantage of this approach is that we can track any malloc bytes, even if they're very short-lived. The check whether to do a GC or not happens in MaybeGC. So even if lots of memory is allocated and then quickly freed, it won't cause a GC as long as a MaybeGC doesn't happen in between.

I'm hoping this will allow people in Gecko to inform the JS engine of all malloc bytes, regardless of whether they're GCable or not. This should help a lot in cases where a GC would free lots of objects, but we're just not smart enough to GC right now.
Attachment #600527 - Flags: review?(anygregor)
Thanks for doing this--we've had several bad GC bugs in the past because of the old, inaccurate, accounting.
Comment on attachment 600527 [details] [diff] [review]
patch

Where is triggerMallocGC used?
Attachment #600527 - Flags: review?(anygregor) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/e4f70bd4f96d

I took out triggerMallocGC. It wasn't supposed to be there.
Target Milestone: --- → mozilla13
https://hg.mozilla.org/mozilla-central/rev/e4f70bd4f96d
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Depends on: 734763
You need to log in before you can comment on or make changes to this bug.