Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
n-api: adds function to adjust external memory
Changed napi_adjust_external_memory() signature to be more
consistent with the rest of the API

Fixes: #13928
  • Loading branch information
Chris Young committed Aug 25, 2017
commit fd40a07606fdd73c24e49831da5e647ce3b3d56c
10 changes: 6 additions & 4 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3394,22 +3394,24 @@ support it:
* If the function is not available, provide an alternate implementation
that does not use the function.

## Garbage Collection
## Memory Management

### napi_adjust_external_memory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you would need a "Garbage Collection" heading here as well, so as to not categorize it under "Version Management".

<!-- YAML
added: REPLACEME
-->
```C
NAPI_EXTERN int64_t napi_adjust_external_memory(napi_env env,
int64_t change_in_bytes);
NAPI_EXTERN napi_status napi_adjust_external_memory(napi_env env,
int64_t change_in_bytes,
int64_t* result);
```

- `[in] env`: The environment that the API is invoked under.
- `[in] change_in_bytes`: The change in externally allocated memory that is
kept alive by JavaScript objects.
- `[out] result`: The adjusted value

Returns `int64_t` the adjusted value.
Returns `napi_ok` if the API succeeded.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this is missing a description of what the method actually does.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a description below


This function gives V8 an indication of the amount of externally allocated
memory that is kept alive by JavaScript objects (i.e. a JavaScript object
Expand Down
3 changes: 1 addition & 2 deletions test/addons-napi/test_general/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,4 @@ assert.strictEqual(test_general.finalizeWasCalled(), false,
'finalize callback was not called upon garbage collection');

// test napi_adjust_external_memory
const adjustedValue = test_general.testAdjustExternalMemory();
assert.strictEqual(typeof adjustedValue, 'number');
assert.strictEqual(typeof test_general.testAdjustExternalMemory(), 'number');