Description
This function is tied to the JavaScriptCore back-end.
V8 has a similar function, AdjustAmountOfExternalAllocatedMemory(). The difference is that it can be used to record a decrease in externally allocated memory, and that the information is retained between garbage collection runs:
* Adjusts the amount of registered external memory. Used to give * V8 an indication of the amount of externally allocated memory * that is kept alive by JavaScript objects. V8 uses this to decide * when to perform global garbage collections. Registering * externally allocated memory will trigger global garbage * collections more often than otherwise in an attempt to garbage * collect the JavaScript objects keeping the externally allocated * memory alive.
This philosophy is different from JavaScriptCore's (from Collector.cpp):
// Our frequency of garbage collection tries to balance memory use against speed // by collecting based on the number of newly created values. However, for values // that hold on to a great deal of memory that's not in the form of other JS values, // that is not good enough - in some cases a lot of those objects can pile up and // use crazy amounts of memory without a GC happening. So we track these extra // memory costs. Only unusually large objects are noted, and we only keep track // of this extra cost until the next GC. In garbage collected languages, most values // are either very short lived temporaries, or have extremely long lifetimes. So // if a large value survives one garbage collection, there is not much point to // collecting more frequently as long as it stays alive.