Skip to content

Commit 17db006

Browse files
authored
fix: don't leak code cache data (#146)
1 parent 454bac2 commit 17db006

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

NativeScript/runtime/ModuleInternal.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,11 +422,13 @@
422422
}
423423

424424
Local<UnboundScript> unboundScript = script->GetUnboundScript();
425+
// CachedData returned by this function should be owned by the caller (v8 docs)
425426
ScriptCompiler::CachedData* cachedData = ScriptCompiler::CreateCodeCache(unboundScript);
426427

427428
int length = cachedData->length;
428429
std::string cachePath = GetCacheFileName(path + ".cache");
429430
tns::WriteBinary(cachePath, cachedData->data, length);
431+
delete cachedData;
430432
}
431433

432434
std::string ModuleInternal::GetCacheFileName(const std::string& path) {

0 commit comments

Comments
 (0)