本文整理了Java中com.eclipsesource.v8.V8.getObjectReferenceCount()
方法的一些代码示例,展示了V8.getObjectReferenceCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。V8.getObjectReferenceCount()
方法的具体详情如下:
包路径:com.eclipsesource.v8.V8
类名称:V8
方法名:getObjectReferenceCount
[英]Returns the number of Object References for this runtime.
[中]返回此运行时的对象引用数。
代码示例来源:origin: eclipsesource/J2V8
v8RuntimePtr = 0L;
released = true;
if (reportMemoryLeaks && (getObjectReferenceCount() > 0)) {
throw new IllegalStateException(getObjectReferenceCount() + " Object(s) still exist in runtime");
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testObjectReferenceZero() {
long objectReferenceCount = v8.getObjectReferenceCount();
assertEquals(0, objectReferenceCount);
}
代码示例来源:origin: eclipsesource/J2V8
v8RuntimePtr = 0L;
released = true;
if (reportMemoryLeaks && (getObjectReferenceCount() > 0)) {
throw new IllegalStateException(getObjectReferenceCount() + " Object(s) still exist in runtime");
代码示例来源:origin: eclipsesource/J2V8
@SuppressWarnings("resource")
@Test
public void testV8ArrayHandlerExceptionDuringCreation() {
ReferenceHandler referenceHandler = mock(ReferenceHandler.class);
doThrow(new RuntimeException()).when(referenceHandler).v8HandleCreated(any(V8Object.class));
v8.addReferenceHandler(referenceHandler);
try {
new V8Array(v8);
} catch (Exception e) {
assertEquals(0, v8.getObjectReferenceCount());
return;
}
fail("Exception should have been caught.");
}
代码示例来源:origin: eclipsesource/J2V8
@SuppressWarnings("resource")
@Test
public void testV8ArrayBufferHandlerExceptionDuringCreation() {
ReferenceHandler referenceHandler = mock(ReferenceHandler.class);
doThrow(new RuntimeException()).when(referenceHandler).v8HandleCreated(any(V8Value.class));
v8.addReferenceHandler(referenceHandler);
try {
new V8ArrayBuffer(v8, 100);
} catch (Exception e) {
assertEquals(0, v8.getObjectReferenceCount());
return;
}
fail("Exception should have been caught.");
}
代码示例来源:origin: eclipsesource/J2V8
@SuppressWarnings("resource")
@Test
public void testV8ObjectHandlerExceptionDuringCreation() {
ReferenceHandler referenceHandler = mock(ReferenceHandler.class);
doThrow(new RuntimeException()).when(referenceHandler).v8HandleCreated(any(V8Object.class));
v8.addReferenceHandler(referenceHandler);
try {
new V8Object(v8);
} catch (Exception e) {
assertEquals(0, v8.getObjectReferenceCount());
return;
}
fail("Exception should have been caught.");
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testMemoryManagerReleasesReturnedObjects() {
MemoryManager memoryManager = new MemoryManager(v8);
v8.executeScript("foo = {}; foo");
assertEquals(1, v8.getObjectReferenceCount());
memoryManager.release();
assertEquals(0, v8.getObjectReferenceCount());
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testObjectReferenceCountReleased() {
V8Object object = new V8Object(v8);
object.close();
long objectReferenceCount = v8.getObjectReferenceCount();
assertEquals(0, objectReferenceCount);
}
代码示例来源:origin: eclipsesource/J2V8
@SuppressWarnings("resource")
@Test
public void testWeakReferenceReducesObjectCount() {
new V8Object(v8).setWeak();
assertEquals(0, v8.getObjectReferenceCount());
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testObjectReferenceCountOne() {
V8Object object = new V8Object(v8);
long objectReferenceCount = v8.getObjectReferenceCount();
assertEquals(1, objectReferenceCount);
object.close();
}
代码示例来源:origin: eclipsesource/J2V8
@SuppressWarnings("resource")
@Test
public void testNestedMemoryManagers() {
MemoryManager memoryManager1 = new MemoryManager(v8);
MemoryManager memoryManager2 = new MemoryManager(v8);
new V8Object(v8);
memoryManager2.release();
new V8Object(v8);
assertEquals(1, v8.getObjectReferenceCount());
memoryManager1.release();
assertEquals(0, v8.getObjectReferenceCount());
}
代码示例来源:origin: eclipsesource/J2V8
@SuppressWarnings("resource")
@Test
public void testMemoryManagerReleasesObjects() {
MemoryManager memoryManager = new MemoryManager(v8);
new V8Object(v8);
memoryManager.release();
assertEquals(0, v8.getObjectReferenceCount());
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testMemoryManagerReleasesFunctions() {
MemoryManager memoryManager = new MemoryManager(v8);
v8.executeScript("(function() {})");
memoryManager.release();
assertEquals(0, v8.getObjectReferenceCount());
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testReleasedMemoryManagerDoesTrackObjects() {
MemoryManager memoryManager = new MemoryManager(v8);
memoryManager.release();
V8Object object = new V8Object(v8);
assertEquals(1, v8.getObjectReferenceCount());
object.close();
}
代码示例来源:origin: eclipsesource/J2V8
@Test
public void testMemoryReferenceCount() {
MemoryManager memoryManager = new MemoryManager(v8);
v8.executeScript("(function() {})");
assertEquals(1, memoryManager.getObjectReferenceCount());
memoryManager.release();
assertEquals(0, v8.getObjectReferenceCount());
}
内容来源于网络,如有侵权,请联系作者删除!