C API for reporting extra memory cost
Hi, With the C API there doesn't seem to be a way to indicate that an object has allocated memory outside the JS heap. Internally, e.g. JSArray calls a function reportExtraMemoryCost() to give the GC a hint that it might want to run sooner rather than later. It would be nice if this were possible when implementing a custom class through the C API as well. Any opinions on exposing this functionality in the C API? Is it too low-level / implementation-dependent? The stop-gap solution I'm employing is to have the application keep track of extra allocations itself and call JSGarbageCollect() once it reaches a threshold, essentially duplicating what reportExtraMemoryCost() does but with less information for making the decision on when to trigger the collection. On the other hand, one could argue that this API is outside the scope of JSC and instead one should rely on e.g. OS notifications that the system is running low on memory, and only call JSGarbageCollect() at that point. That depends on platform support though, I'm not sure for which platforms it's possible. If exposing reportExtraMemoryCost() as-is is acceptable, I'll go ahead and create the patch. Otherwise, suggestions for alternative approaches are welcome. :) Regards, Kent
participants (1)
-
Kent Hansen