Skip to content

Conversation

@wenyongh
Copy link
Collaborator

@wenyongh wenyongh commented Aug 29, 2022

Report the memory leak info when building iwasm with cmake .. -DWAMR_BUILD_GC_VERIFY=1.

Merge bytecodealliance:main into wenyongh:enable_mem_leak_check
&& (hmu_t *)((char *)cur + hmu_get_size(cur)) != end) {
os_printf("Memory leak detected:\n");
gci_dump(heap);
#if WASM_ENABLE_SPEC_TEST != 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a config BH_EXIT_ON_GC_VERIFY_ERROR and exit(-1) here when it is enabled? This will be more friendly to instrumentation test framework

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will the return value -1 be gotten by the runtime embedder?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will the return value -1 be gotten by the runtime embedder?

the -1 will be the exit code of the process and will be gotten by another process (instrument daemon server)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the exit(-1) in wasm_runtime_memory_destroy(), wasm_memory.c, for global heap only. As wasm app heap also uses ems gc, if it has memory leak, it will exit firstly, the global heap memory leak check will be ignored.

#if WASM_ENABLE_GLOBAL_HEAP_POOL != 0
#ifdef __NuttX__
static char global_heap_buf[WASM_GLOBAL_HEAP_SIZE * BH_KB] = { 0 };
#elif WASM_ENABLE_SPEC_TEST != 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about merge these three definitions into one and define a platform dependent size (WASM_GLOBAL_HEAP_SIZE) for it ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I defined the WASM_GLOBAL_HEAP_SIZE with unit bytes but not KB, is it OK for Nuttx?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to change

CFLAGS += -DWASM_GLOBAL_HEAP_SIZE=$(CONFIG_INTERPRETERS_WAMR_GLOBAL_HEAP_POOL_SIZE)
together to get correct heap pool size.

Copy link
Collaborator Author

@wenyongh wenyongh Sep 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to change, like this?

CFLAGS += -DWASM_GLOBAL_HEAP_SIZE="$(CONFIG_INTERPRETERS_WAMR_GLOBAL_HEAP_POOL_SIZE) * 1024" 

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it works.

Merge bytecodealliance:main into wenyongh:enable_mem_leak_check
@wenyongh wenyongh changed the title [WIP] Enable mem leak check Enable memory leak check Aug 31, 2022
@wenyongh wenyongh merged commit d095876 into bytecodealliance:main Sep 1, 2022
@wenyongh wenyongh deleted the enable_mem_leak_check branch September 4, 2022 07:59
vickiegpt pushed a commit to vickiegpt/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
Report the memory leak info when building iwasm with
`cmake .. -DWAMR_BUILD_GC_VERIFY=1`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants