Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 8 additions & 1 deletion ext/v8/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace rr {
defineSingletonMethod("New", &New).

defineMethod("Dispose", &Isolate::Dispose).
defineMethod("Equals", &rr::Isolate::PointerEquals).
defineMethod("Equals", &Isolate::PointerEquals).
defineMethod("NumberOfHeapSpaces", &Isolate::NumberOfHeapSpaces).

store(&Class);
}
Expand Down Expand Up @@ -38,6 +39,12 @@ namespace rr {
return Qnil;
}

VALUE Isolate::NumberOfHeapSpaces(VALUE self) {
Isolate isolate(self);
size_t spaces = isolate->NumberOfHeapSpaces();
return SIZET2NUM(spaces);
}

template <>
void Pointer<v8::Isolate>::unwrap(VALUE value) {
Data_Get_Struct(value, class v8::Isolate, pointer);
Expand Down
2 changes: 2 additions & 0 deletions ext/v8/isolate.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ namespace rr {

static VALUE Dispose(VALUE self);

static VALUE NumberOfHeapSpaces(VALUE self);

/**
* Recent versions of V8 will segfault unless you pass in an
* ArrayBufferAllocator into the create params of an isolate. This
Expand Down
4 changes: 4 additions & 0 deletions spec/c/isolate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
it "can be disposed of" do
isolate.Dispose()
end

it "has has heap spaces" do
expect(isolate.NumberOfHeapSpaces()).to be >= 1
end
end