Add operational mode for jerry_gc API call. (#2385)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-06-15 09:31:48 +02:00
committed by yichoi
parent bc827cb497
commit 1044523af7
8 changed files with 59 additions and 15 deletions
+32 -3
View File
@@ -68,6 +68,18 @@ Option bits for [jerry_parse](#jerry_parse) and
- JERRY_PARSE_NO_OPTS - no options passed
- JERRY_PARSE_STRICT_MODE - enable strict mode
## jerry_gc_mode_t
Set garbage collection operational mode
- JERRY_GC_SEVERITY_LOW - free unused objects
- JERRY_GC_SEVERITY_HIGH - free as much memory as possible
The difference between `JERRY_GC_SEVERITY_LOW` and `JERRY_GC_SEVERITY_HIGH`
is that the former keeps memory allocated for performance improvements such
as property hash tables for large objects. The latter frees all possible
memory blocks but the performance may drop after the garbage collection.
## jerry_generate_snapshot_opts_t
Flags for [jerry_generate_snapshot](#jerry_generate_snapshot) and
@@ -705,13 +717,30 @@ Performs garbage collection.
```c
void
jerry_gc (void);
jerry_gc (jerry_gc_mode_t mode);
```
- `mode` - operational mode, see [jerry_gc_mode_t](#jerry_gc_mode_t)
**Example**
[doctest]: # ()
```c
jerry_gc ();
#include "jerryscript.h"
int
main (void)
{
jerry_init (JERRY_INIT_EMPTY);
jerry_value_t object_value = jerry_create_object ();
jerry_release_value (object_value);
jerry_gc (JERRY_GC_SEVERITY_LOW);
jerry_cleanup ();
}
```
**See also**
@@ -1601,7 +1630,7 @@ jerry_value_is_undefined (const jerry_value_t value)
Returns the JavaScript type
for a given value as a [jerry_type_t](#jerry_type_t) enum value.
This is a similar operation as the 'typeof' operator
This is a similar operation to the 'typeof' operator
in the standard with an exception that the 'null'
value has its own enum value.