Introspected objects should report correct malloc size
Submitted by Havoc Pennington
Link to original bug (#630908)
Description
we've had trouble with GdkPixbuf in particular because it may be several megabytes or more, but spidermonkey thinks it's just the object proxy's size. This means you can generate gigabytes of pixbufs and never GC.
It looks like new spidermonkey has JS_updateMallocCounter() and I think it would be correct to do something like:
JS_updateMallocCounter(pixbuf->rowstride * pixbuf->height);
when creating a pixbuf.
How to do this generically I don't know... it almost requires an extra hook to be registered with each GType.
An alternative approach would be to install a g_malloc mem vtable that does JS_updateMallocCounter on all g_malloc. Probably the most sane approach, really.
I don't think updateMallocCounter has to be precise; it's never decremented again or anything. It just has to generally give spidermonkey an idea how much memory we've "gone through" lately, as I understand it.