Implement memory profiler, optimize memory usage, modify code indent (#35)
This commit is contained in:
@ -52,6 +52,8 @@ int bh_memory_init_with_allocator(void *malloc_func, void *free_func);
|
||||
*/
|
||||
void bh_memory_destroy();
|
||||
|
||||
#if BEIHAI_ENABLE_MEMORY_PROFILING == 0
|
||||
|
||||
/**
|
||||
* This function allocates a memory chunk from system
|
||||
*
|
||||
@ -68,6 +70,32 @@ void* bh_malloc(unsigned int size);
|
||||
*/
|
||||
void bh_free(void *ptr);
|
||||
|
||||
#else
|
||||
|
||||
void* bh_malloc_profile(const char *file, int line, const char *func, unsigned int size);
|
||||
void bh_free_profile(const char *file, int line, const char *func, void *ptr);
|
||||
|
||||
#define bh_malloc(size) bh_malloc_profile(__FILE__, __LINE__, __func__, size)
|
||||
#define bh_free(ptr) bh_free_profile(__FILE__, __LINE__, __func__, ptr)
|
||||
|
||||
/**
|
||||
* Print current memory profiling data
|
||||
*
|
||||
* @param file file name of the caller
|
||||
* @param line line of the file of the caller
|
||||
* @param func function name of the caller
|
||||
*/
|
||||
void memory_profile_print(const char *file, int line, const char *func, int alloc);
|
||||
|
||||
/**
|
||||
* Summarize memory usage and print it out
|
||||
* Can use awk to analyze the output like below:
|
||||
* awk -F: '{print $2,$4,$6,$8,$9}' OFS="\t" ./out.txt | sort -n -r -k 1
|
||||
*/
|
||||
void memory_usage_summarize();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -48,6 +48,9 @@
|
||||
/* WASM Interpreter labels-as-values feature */
|
||||
#define WASM_ENABLE_LABELS_AS_VALUES 1
|
||||
|
||||
/* WASM Branch Block address hashmap */
|
||||
#define WASM_ENABLE_HASH_BLOCK_ADDR 0
|
||||
|
||||
/* Heap and stack profiling */
|
||||
#define BEIHAI_ENABLE_MEMORY_PROFILING 0
|
||||
|
||||
@ -77,14 +80,22 @@
|
||||
#define WORKING_FLOW_HEAP_SIZE 0
|
||||
*/
|
||||
|
||||
/* Default/min/max heap size of each app */
|
||||
#define APP_HEAP_SIZE_DEFAULT (48 * 1024)
|
||||
/* Default min/max heap size of each app */
|
||||
#define APP_HEAP_SIZE_DEFAULT (8 * 1024)
|
||||
#define APP_HEAP_SIZE_MIN (2 * 1024)
|
||||
#define APP_HEAP_SIZE_MAX (1024 * 1024)
|
||||
|
||||
/* Default wasm stack size of each app */
|
||||
#define DEFAULT_WASM_STACK_SIZE (8 * 1024)
|
||||
|
||||
/* Default/min/max stack size of each app thread */
|
||||
#ifndef __ZEPHYR__
|
||||
#define APP_THREAD_STACK_SIZE_DEFAULT (20 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MIN (16 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MAX (256 * 1024)
|
||||
|
||||
#else
|
||||
#define APP_THREAD_STACK_SIZE_DEFAULT (4 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MIN (2 * 1024)
|
||||
#define APP_THREAD_STACK_SIZE_MAX (256 * 1024)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user