Add API for get the memory stats (#1923)

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
This commit is contained in:
Zidong Jiang
2017-08-04 15:44:37 +08:00
committed by Zoltan Herczeg
parent 8b5fe254d9
commit c242248b47
9 changed files with 165 additions and 5 deletions
+50
View File
@@ -169,6 +169,26 @@ typedef struct
} jerry_property_descriptor_t;
```
## jerry_heap_stats_t
**summary**
Description of JerryScript heap memory stats.
It is for memory profiling.
**Prototype**
```c
typedef struct
{
size_t version /**< the version of the stats struct */
size_t size; /**< heap total size */
size_t allocated_bytes; /**< currently allocated bytes */
size_t peak_allocated_bytes; /**< peak allocated bytes */
size_t reserved[4]; /**< padding for future extensions */
} jerry_heap_stats_t;
```
## jerry_external_handler_t
**Summary**
@@ -523,6 +543,36 @@ main (void)
- [jerry_cleanup](#jerry_cleanup)
## jerry_get_memory_stats
**Summary**
Get heap memory stats.
**Prototype**
```c
bool
jerry_get_memory_stats (jerry_heap_stats_t *out_stats_p);
```
- `out_stats_p` - out parameter, that provides the heap statistics.
- return value
- true, if run was successful
- false, otherwise. Usually it is because the MEM_STATS feature is not enabled.
**Example**
```c
jerry_heap_stats_t stats = {0};
bool get_stats_ret = jerry_get_memory_stats (&stats);
```
**See also**
- [jerry_init](#jerry_init)
## jerry_gc
**Summary**