MCPcopy Create free account
hub / github.com/Kitware/VTK / main

Method main

Wrapping/Java/Testing/Java/vtk/test/ManualGC.java:29–64  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

27 }
28
29 public static void main(String[] args) {
30 try {
31 vtkJavaTesting.Initialize(args, true);
32 int count = 0;
33 long timeout = System.currentTimeMillis() + 60000; // +1 minute
34 while (System.currentTimeMillis() < timeout) {
35 // When the selection is deleted,
36 // it will decrement the array's reference count.
37 // If GC is done on a different thread, this will
38 // interfere with the Register/Delete calls on
39 // this thread and cause a crash. In general, the code
40 // executed in a C++ destructor can do anything, so it
41 // is never safe to delete objects on one thread while
42 // using them on another.
43 //
44 // Thus we no longer implement finalize() for VTK objects.
45 // We must manually call
46 // vtkObject.JAVA_OBJECT_MANAGER.gc(true/false) when we
47 // want to collect unused VTK objects.
48 vtkIdTypeArray arr = createSelection();
49 for (int i = 0; i < 10000; ++i) {
50 arr.Register(null);
51 vtkObjectBase.VTKDeleteReference(arr.GetVTKId());
52 }
53 ++count;
54 if (count % 100 == 0) {
55 vtkReferenceInformation infos = vtkObject.JAVA_OBJECT_MANAGER.gc(false);
56 System.out.println(infos.toString());
57 }
58 }
59 vtkJavaTesting.Exit(vtkJavaTesting.PASSED);
60 } catch (Throwable e) {
61 e.printStackTrace();
62 vtkJavaTesting.Exit(vtkJavaTesting.FAILED);
63 }
64 }
65}

Callers

nothing calls this directly

Calls 6

createSelectionMethod · 0.95
toStringMethod · 0.95
ExitMethod · 0.80
gcMethod · 0.65
InitializeMethod · 0.45
RegisterMethod · 0.45

Tested by

no test coverage detected