Skip to content

Commit f53dba1

Browse files
galpeterdbatyai
authored andcommitted
Add dependency info for accessing memstats from API (#2979)
The documentation of `jerry_get_memory_stats` method was missing the requirements on what build option or feature is required. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
1 parent ec11a7b commit f53dba1

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

docs/02.API-REFERENCE.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Enum that contains the following elements:
88
- JERRY_INIT_SHOW_OPCODES - dump byte-code to log after parse
99
- JERRY_INIT_SHOW_REGEXP_OPCODES - dump regexp byte-code to log after compilation
1010
- JERRY_INIT_MEM_STATS - dump memory statistics
11-
- JERRY_INIT_MEM_STATS_SEPARATE - dump memory statistics and reset peak values after parse
12-
- JERRY_INIT_DEBUGGER - deprecated, an unused placeholder now
11+
- JERRY_INIT_MEM_STATS_SEPARATE - **deprecated**, dump memory statistics and reset peak values after parse
12+
- JERRY_INIT_DEBUGGER - **deprecated**, an unused placeholder now
1313

1414
## jerry_type_t
1515

@@ -790,6 +790,14 @@ main (void)
790790

791791
Get heap memory stats.
792792

793+
**Notes**:
794+
- The engine must be initialized with the `JERRY_INIT_MEM_STATS` option to allow
795+
heap statistic collections. See [jerry_init](#jerry_init)
796+
- This API depends on a build option (`JERRY_MEM_STATS`) and can be checked
797+
in runtime with the `JERRY_FEATURE_MEM_STATS` feature enum value,
798+
see: [jerry_is_feature_enabled](#jerry_is_feature_enabled).
799+
800+
793801
**Prototype**
794802

795803
```c
@@ -799,12 +807,15 @@ jerry_get_memory_stats (jerry_heap_stats_t *out_stats_p);
799807

800808
- `out_stats_p` - out parameter, that provides the heap statistics.
801809
- return value
802-
- true, if run was successful
803-
- false, otherwise. Usually it is because the MEM_STATS feature is not enabled.
810+
- true, if stats were written into the `out_stats_p` pointer.
811+
- false, otherwise. Usually it is because the `JERRY_FEATURE_MEM_STATS` feature is not enabled.
804812

805813
**Example**
806814

807815
```c
816+
jerry_init (JERRY_INIT_MEM_STATS);
817+
// ...
818+
808819
jerry_heap_stats_t stats = {0};
809820
bool get_stats_ret = jerry_get_memory_stats (&stats);
810821
```

0 commit comments

Comments
 (0)