MCPcopy Create free account
hub / github.com/GNOME/gjs / gjs_dump_heap

Function gjs_dump_heap

modules/system.cpp:111–131  ·  view source on GitHub ↗

This can reduce performance, so should be used for debugging only. js::CollectNurseryBeforeDump() promotes any live objects in the nursery to the tenured heap. This is slow, but this way, we are certain to get an accurate picture of the heap.

Source from the content-addressed store, hash-verified

109// the tenured heap. This is slow, but this way, we are certain to get an
110// accurate picture of the heap.
111static bool gjs_dump_heap(JSContext* cx, unsigned argc, JS::Value* vp) {
112 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
113 Gjs::AutoChar filename;
114
115 if (!gjs_parse_call_args(cx, "dumpHeap", args, "|F", "filename", &filename))
116 return false;
117
118 LogFile file(filename);
119 if (file.has_error()) {
120 gjs_throw(cx, "Cannot dump heap to %s: %s", filename.get(),
121 file.errmsg());
122 return false;
123 }
124 js::DumpHeap(cx, file.fp(), js::CollectNurseryBeforeDump);
125
126 gjs_debug(GJS_DEBUG_CONTEXT, "Heap dumped to %s",
127 filename ? filename.get() : "stdout");
128
129 args.rval().setUndefined();
130 return true;
131}
132
133static bool gjs_gc(JSContext* cx, unsigned argc, JS::Value* vp) {
134 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);

Callers

nothing calls this directly

Calls 7

gjs_parse_call_argsFunction · 0.85
gjs_throwFunction · 0.85
gjs_debugFunction · 0.85
has_errorMethod · 0.80
errmsgMethod · 0.80
fpMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected