On Wed, Feb 18, 2015 at 6:09 PM, obastemur <obaste...@gmail.com> wrote:
> Some hours ago, we've released jxcore on github (a nodejs distro with 
> SpiderMonkey) (https://github.com/jxcore/jxcore)..
>
> Thanks for this great JavaScript engine though!
>
> Showing the heap memory usage from underlying engine is one of the very few 
> things left I'm trying to do with SpiderMonkey. Is there an easy way? or I 
> should wrap JS_malloc/JS_free methods ? (If it makes sense?)

If you just want to wrap allocation/deallocation, #define
JS_USE_CUSTOM_ALLOCATOR and provide a jscustomallocator.h function
that implements js_malloc, js_calloc, js_realloc, js_free and
js_strdup -- see public/Utility for details.

If you want more detailed measurements, look at
public/MemoryMetrics.h, which provides a huge amount of detail and is
used as the basis for the JS measurements available in Firefox's
about:memory. The entry point is CollectRuntimeStats(). You'll need to
provide a mozilla::MallocSizeOf function (via RuntimeStats) that works
something like malloc_usable_size(). You'll be able to (and likely
should) use nullptr for the ObjectPrivateVisitor argument.

Hope this helps.

Nick
_______________________________________________
dev-tech-js-engine-internals mailing list
dev-tech-js-engine-internals@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals

Reply via email to