jerryscript icon indicating copy to clipboard operation
jerryscript copied to clipboard

Jerry API for retrieving heap stats.

Open ILyoan opened this issue 11 years ago • 4 comments

For profiling and tracing memory usage during running a program. It would be useful to have API for getting heap memory stats.

Interesting numbers are total heap size, allocated bytes, and peak bytes.

typedef struct jerry_api_heap_status_t 
{
  size_t heap_size;
  size_t allocated_bytes;
  size_t peak_allocated_bytes;
} jerry_api_heap_stats_t;

void jerry_api_heap_stats (jerry_api_heap_stats_t*);

ILyoan avatar Oct 22 '15 07:10 ILyoan

Important numbers are:

   Peak allocated chunks count = 1386
   Peak allocated = 33469 bytes
   Peak waste = 55235 bytes

Currently available:

Heap stats:
   Heap size = 258048 bytes
   Chunk size = 64 bytes
   Allocated chunks count = 0
   Allocated = 0 bytes
   Waste = 0 bytes
   Peak allocated chunks count = 1386
   Peak allocated = 33469 bytes
   Peak waste = 55235 bytes

Pools stats:
  Chunk size: 8
   Pools: 0
   Allocated chunks: 0
   Free chunks: 0
   Peak pools: 380
   Peak allocated chunks: 3039

egavrin avatar Oct 22 '15 10:10 egavrin

Additionally, it'd be nice to have API for resetting statistics: void jerry_api_mem_stats_reset (); - since we don't need to know the allocated peek after parsing, for example.

egavrin avatar Oct 22 '15 10:10 egavrin

@egavrin Thanks for your opinion, I agree with you. I'll prepare PR for this issue.

ILyoan avatar Nov 04 '15 02:11 ILyoan

No plans to implement this at the moment.

zherczeg avatar Jan 31 '17 13:01 zherczeg