Skip to content

Commit 200bd9b

Browse files
Merge pull request #139 from lightpanda-io/mem-pressure-notification
expose v8__Isolate__MemoryPressureNotification
2 parents eb9dd8b + 7a7f1d6 commit 200bd9b

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/binding.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ void v8__Isolate__LowMemoryNotification(v8::Isolate* self) {
397397
self->LowMemoryNotification();
398398
}
399399

400+
void v8__Isolate__MemoryPressureNotification(v8::Isolate* self, v8::MemoryPressureLevel level) {
401+
self->MemoryPressureNotification(level);
402+
}
403+
400404
void v8__Isolate__GetHeapStatistics(
401405
v8::Isolate* self,
402406
v8::HeapStatistics* stats) {

src/binding.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,12 @@ void v8__Isolate__TerminateExecution(Isolate* self);
260260
bool v8__Isolate__IsExecutionTerminating(Isolate* self);
261261
void v8__Isolate__CancelTerminateExecution(Isolate* self);
262262
void v8__Isolate__LowMemoryNotification(Isolate* self);
263+
typedef enum MemoryPressureLevel {
264+
kNone = 0,
265+
kModerate = 1,
266+
kCritical = 2
267+
} MemoryPressureLevel;
268+
void v8__Isolate__MemoryPressureNotification(Isolate* self, MemoryPressureLevel level);
263269
typedef struct HeapStatistics {
264270
size_t total_heap_size;
265271
size_t total_heap_size_executable;

src/v8.zig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,16 @@ pub const Isolate = struct {
400400
c.v8__Isolate__LowMemoryNotification(self.handle);
401401
}
402402

403+
pub const MemoryPressureLevel = enum(u32) {
404+
none = c.kNone,
405+
moderate = c.kModerate,
406+
critical = c.kCritical,
407+
};
408+
409+
pub fn memoryPressureNotification(self: Self, level: MemoryPressureLevel) void {
410+
c.v8__Isolate__MemoryPressureNotification(self.handle, @intFromEnum(level));
411+
}
412+
403413
pub fn getHeapStatistics(self: Self) c.HeapStatistics {
404414
var res: c.HeapStatistics = undefined;
405415
c.v8__Isolate__GetHeapStatistics(self.handle, &res);

0 commit comments

Comments
 (0)