# HG changeset patch # User Atul Varma # Date 1245893784 25200 # Node ID b36c15de56f6e8891223ec2fa04861eb7d181092 # Parent 1aba1b7a0a2ca9941c6326fbd0a260ac2272947f added a size property to info diff -r 1aba1b7a0a2c -r b36c15de56f6 memory_profiler.cpp --- a/memory_profiler.cpp Wed Jun 24 18:32:14 2009 -0700 +++ b/memory_profiler.cpp Wed Jun 24 18:36:24 2009 -0700 @@ -1,4 +1,5 @@ #include "jsdhash.h" +#include "jsdbgapi.h" #include "memory_profiler.h" #include "server_socket.h" @@ -125,7 +126,8 @@ JSObject *info = JS_NewObject(cx, NULL, NULL, NULL); JSObject *target = (JSObject *) id; - JSClass *classp = JS_GET_CLASS(tracingState.tracer.context, target); + JSContext *targetCx = tracingState.tracer.context; + JSClass *classp = JS_GET_CLASS(targetCx, target); if (classp != NULL) { // TODO: Should really be using an interned string here or something. JSString *name = JS_NewStringCopyZ(cx, classp->name); @@ -140,6 +142,14 @@ } } + if (!JS_DefineProperty( + cx, info, "size", + INT_TO_JSVAL(JS_GetObjectTotalSize(targetCx, target)), + NULL, NULL, JSPROP_ENUMERATE)) { + JS_ReportOutOfMemory(cx); + return JS_FALSE; + } + *rval = OBJECT_TO_JSVAL(info); } else *rval = JSVAL_NULL;