[vtkusers] VTK Java memory leak
James Labiak
jim at jslengineeringsoftware.com
Fri Feb 13 09:36:57 EST 2015
Thanks to all for the quick responses. These are great suggestions and
are helping a lot to narrow-down the problem.
Regards,
Jim
-------------------------------------------------------
On quick suggestion configure vtk to have VTK_DEBUG_LEAKS on (on the
advanced set of cmake options) and rebuild.
Then when you exit the program it will tell you what VTK instances have
not been entirely dereferences and thus not yet deallocated.
That should help narrow it down.
David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909
---------------------------------------------------------
Jim,
here is the strategy I've used:
1) make sure you build debug with "VTK_DEBUG_LEAKS" enabled.
2) use google-test or some other framework that will report a test failure if program exits with non-zero code.
3) write tests in increasing complexity until you cause a leak in a unit test; then track it down in whatever class(es) are at fault.
For example, below are a simple and medium complexity test; they are exercising a couple of classes that derive from VTK's base classes. Initially, the first test reported a leak; I fixed that vtkSphereWidgetWrapper class. Then, the medium complexity one still failed; this required touching a few files to fix.
// simplest
TEST(CrashTest,ValgrindMe_vtkSphereWidgetWrapperNoRenderWindow)
{
for( int outer = 0; outer < 1; outer++ ) {
vtkUniquePtr<vtkSphereRepresentationWrapper> tmp;
EXPECT_TRUE(tmp.get()!=nullptr);
}
}
// medium complexity
TEST(MemTest,ValgrindMe_vtkSphereWidgetWrapper)
{
vtkUniquePtr<vtkRenderer> ren;
vtkUniquePtr<vtkRenderWindow> win;
ren->SetRenderWindow(win.get());
{
vtkUniquePtr<vtkSphereWidgetWrapper> tmp;
tmp->SetCurrentRenderer(ren.get());
tmp->Modified();
tmp->GetRepresentation()->Modified();
win->Render();
}
}
_______________________
regards,
peter karasev
------------------------------------------------------------------------------
On 2/11/2015 10:31 AM, David E DeMarle wrote:
> On quick suggestion configure vtk to have VTK_DEBUG_LEAKS on (on the
> advanced set of cmake options) and rebuild.
>
> Then when you exit the program it will tell you what VTK instances
> have not been entirely dereferences and thus not yet deallocated.
>
> That should help narrow it down.
>
>
> David E DeMarle
> Kitware, Inc.
> R&D Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
--------------------------------------------------------
> On Wed, Feb 11, 2015 at 10:02 AM, James Labiak
> <jim at jslengineeringsoftware.com
> <mailto:jim at jslengineeringsoftware.com>> wrote:
>
> I have a Java GUI application which runs without memory leaks. It
> loads a database of simulations and displays 2D graphs for output.
> I added VTK code so that I can also display 3D graphs. Now, when I
> repeatedly display/cycle through the the same 4 VTK graphs (or
> different graphs) many times, the program uses increasing memory
> until the computer runs out of RAM and the application fails to
> respond. It seems to have a memory leak related to VTK. Memory is
> only freed when I then kill the application process. I have
> searched for information on this and tried to address various
> potential issues without success. In version 6.0, the VTK garbage
> collection method seems to have been removed. I think that I
> addressed potential reference count issues by providing VTK object
> references that go through the Java object layer. I tried adding
> code to delete VTK objects manually through someVTKObject.Delete()
> but that didn't seem to help. I ran jvisualvm but haven't been
> able to identify what is causing the leak. I am relatively new to
> VTK (and jvisualvm), so I wonder if there is a general strategy to
> address the memory leak issue, or other potential issues that I
> should look for.
> Thanks,
> Jim
> _______________________________________________
> Powered by www.kitware.com <http://www.kitware.com>
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
--
James Labiak
JSL Engineering and Software
6545 Lainhart Rd.
Altamont, NY 12009
Phone: 518-861-1113
Mobile: 231-638-3725
email: jim at jslengineeringsoftware.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150213/1feaaded/attachment.html>
More information about the vtkusers
mailing list