mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-29 10:02:14 +00:00
Enhance some of GC features
* Add a heuristic to run GC before heap block allocation (to reduce fragmentation overhead) * Add logger & visualizer of runtime heap usage (available both in debug/release mode)
This commit is contained in:
parent
eff931b702
commit
8afb3c7fa4
10 changed files with 247 additions and 0 deletions
|
|
@ -112,6 +112,11 @@ void GC_free_hook(void* address)
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef PROFILE_BDWGC
|
||||
const char* bdwgc_log_filename = "bdwgc_log";
|
||||
const char* bdwgc_log_phase = "initial phase";
|
||||
#endif
|
||||
|
||||
void eval(Escargot::Context* context, Escargot::String* str, Escargot::String* fileName, bool shouldPrintScriptResult)
|
||||
{
|
||||
auto result = context->scriptParser().parse(str, fileName);
|
||||
|
|
@ -173,6 +178,19 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
});
|
||||
#endif
|
||||
#ifdef PROFILE_BDWGC
|
||||
remove(bdwgc_log_filename);
|
||||
FILE* fp = fopen(bdwgc_log_filename, "a");
|
||||
if (fp) {
|
||||
fprintf(fp, "GC_no PeakRSS TotalHeap Marked # Phase\n");
|
||||
fclose(fp);
|
||||
}
|
||||
GC_set_on_collection_event([](GC_EventType evtType) {
|
||||
if (GC_EVENT_RECLAIM_START == evtType) {
|
||||
GC_dump_for_graph(bdwgc_log_filename, bdwgc_log_phase);
|
||||
}
|
||||
});
|
||||
#endif
|
||||
#ifndef NDEBUG
|
||||
setbuf(stdout, NULL);
|
||||
setbuf(stderr, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue