Skip to content

Commit

Permalink
Bug 1547310 - Cap the number of SharedScriptData leaks logged. r=jonco
Browse files Browse the repository at this point in the history
Also, reduce the number logged for other tracekinds to 5.

Differential Revision: https://phabricator.services.mozilla.com/D29041

--HG--
extra : moz-landing-system : lando
  • Loading branch information
amccreight committed Apr 29, 2019
1 parent 668700c commit 74bc8c3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/src/gc/GC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3935,7 +3935,7 @@ bool ArenaLists::checkEmptyArenaList(AllocKind kind) {
size_t numLive = 0;
if (!arenaLists(kind).isEmpty()) {
isEmpty = false;
size_t maxCells = 20;
size_t maxCells = 5;
char* env = getenv("JS_GC_MAX_LIVE_CELLS");
if (env && *env) {
maxCells = atol(env);
Expand Down
27 changes: 22 additions & 5 deletions js/src/vm/JSScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3308,17 +3308,34 @@ void js::FreeScriptData(JSRuntime* rt) {
// The table should be empty unless the embedding leaked GC things.
MOZ_ASSERT_IF(rt->gc.shutdownCollectedEverything(), table.empty());

#ifdef DEBUG
size_t numLive = 0;
size_t maxCells = 5;
char* env = getenv("JS_GC_MAX_LIVE_CELLS");
if (env && *env) {
maxCells = atol(env);
}
#endif

for (ScriptDataTable::Enum e(table); !e.empty(); e.popFront()) {
#ifdef DEBUG
SharedScriptData* scriptData = e.front();
fprintf(stderr,
"ERROR: GC found live SharedScriptData %p with ref count %d at "
"shutdown\n",
scriptData, scriptData->refCount());
if (++numLive <= maxCells) {
SharedScriptData* scriptData = e.front();
fprintf(stderr,
"ERROR: GC found live SharedScriptData %p with ref count %d at "
"shutdown\n",
scriptData, scriptData->refCount());
}
#endif
js_free(e.front());
}

#ifdef DEBUG
if (numLive > 0) {
fprintf(stderr, "ERROR: GC found %zu live SharedScriptData at shutdown\n", numLive);
}
#endif

table.clear();
}

Expand Down

0 comments on commit 74bc8c3

Please sign in to comment.