Introducing 'try to give memory back' callback for heap allocator to use upon allocation request that can not be satisfied by the allocator.
This commit is contained in:
@@ -43,12 +43,37 @@
|
||||
*/
|
||||
#define MEM_COMPRESSED_POINTER_WIDTH (MEM_HEAP_OFFSET_LOG - MEM_ALIGNMENT_LOG)
|
||||
|
||||
/**
|
||||
* Severity of a 'try give memory back' request
|
||||
*
|
||||
* The request are posted sequentially beginning from
|
||||
* low to critical until enough memory is freed.
|
||||
*
|
||||
* If not enough memory is freed upon a critical request
|
||||
* then the engine is shut down with ERR_OUT_OF_MEMORY.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_LOW, /* 'low' severity */
|
||||
MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_MEDIUM, /* 'medium' severity */
|
||||
MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_HIGH, /* 'high' severity */
|
||||
MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_CRITICAL /* 'critical' severity */
|
||||
} mem_try_give_memory_back_severity_t;
|
||||
|
||||
/**
|
||||
* A 'try give memory back' callback routine type.
|
||||
*/
|
||||
typedef void (*mem_try_give_memory_back_callback_t) (mem_try_give_memory_back_severity_t);
|
||||
|
||||
extern void mem_init (void);
|
||||
extern void mem_finalize (bool is_show_mem_stats);
|
||||
|
||||
extern uintptr_t mem_compress_pointer (void *pointer);
|
||||
extern void* mem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
|
||||
extern void mem_register_a_try_give_memory_back_callback (mem_try_give_memory_back_callback_t callback);
|
||||
extern void mem_unregister_a_try_give_memory_back_callback (mem_try_give_memory_back_callback_t callback);
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
extern bool mem_is_heap_pointer (void *pointer);
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
|
||||
Reference in New Issue
Block a user