mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-12-23 15:50:11 -05:00
Add bindings to 'v8::Isolate::LowMemoryNotification()' (#459)
This commit is contained in:
parent
de58267948
commit
8513c8fa69
3 changed files with 17 additions and 0 deletions
|
@ -119,6 +119,10 @@ void v8__Isolate__Enter(v8::Isolate* isolate) { isolate->Enter(); }
|
|||
|
||||
void v8__Isolate__Exit(v8::Isolate* isolate) { isolate->Exit(); }
|
||||
|
||||
void v8__Isolate__LowMemoryNotification(v8::Isolate* isolate) {
|
||||
isolate->LowMemoryNotification();
|
||||
}
|
||||
|
||||
void v8__Isolate__GetHeapStatistics(v8::Isolate* isolate,
|
||||
v8::HeapStatistics* s) {
|
||||
isolate->GetHeapStatistics(s);
|
||||
|
|
|
@ -105,6 +105,7 @@ extern "C" {
|
|||
fn v8__Isolate__GetNumberOfDataSlots(this: *const Isolate) -> u32;
|
||||
fn v8__Isolate__Enter(this: *mut Isolate);
|
||||
fn v8__Isolate__Exit(this: *mut Isolate);
|
||||
fn v8__Isolate__LowMemoryNotification(isolate: *mut Isolate);
|
||||
fn v8__Isolate__GetHeapStatistics(this: *mut Isolate, s: *mut HeapStatistics);
|
||||
fn v8__Isolate__SetCaptureStackTraceForUncaughtExceptions(
|
||||
this: *mut Isolate,
|
||||
|
@ -366,6 +367,12 @@ impl Isolate {
|
|||
unsafe { v8__Isolate__Exit(self) }
|
||||
}
|
||||
|
||||
/// Optional notification that the system is running low on memory.
|
||||
/// V8 uses these notifications to attempt to free memory.
|
||||
pub fn low_memory_notification(&mut self) {
|
||||
unsafe { v8__Isolate__LowMemoryNotification(self) }
|
||||
}
|
||||
|
||||
/// Get statistics about the heap memory usage.
|
||||
pub fn get_heap_statistics(&mut self, s: &mut HeapStatistics) {
|
||||
unsafe { v8__Isolate__GetHeapStatistics(self, s) }
|
||||
|
|
|
@ -3414,6 +3414,12 @@ fn heap_statistics() {
|
|||
assert_ne!(s.number_of_native_contexts(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn low_memory_notification() {
|
||||
let mut isolate = v8::Isolate::new(Default::default());
|
||||
isolate.low_memory_notification();
|
||||
}
|
||||
|
||||
fn synthetic_evaluation_steps<'a>(
|
||||
context: v8::Local<'a, v8::Context>,
|
||||
module: v8::Local<v8::Module>,
|
||||
|
|
Loading…
Reference in a new issue