View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0000552 | VTK | (No Category) | public | 2004-01-28 13:22 | 2005-01-20 11:20 | ||||
Reporter | Mathieu Malaterre | ||||||||
Assigned To | Jeff Lee | ||||||||
Priority | low | Severity | major | Reproducibility | always | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | |||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0000552: GDI Resource leak | ||||||||
Description | I have an application that is a mix btw vtk4.2 and java swing. I'm using vtkCanvas which extends vtkPanel. Recently I discovered that vtkPanel leak something called GDI objects. This leackage will after some time lead to unstabillity and crash of my PC (Win 2000). I see the same problem in the example programs following the vtk distribution (f.ex TestVTKCanvas.java) Have anyone else seen this problem ? How can I ensure that vtkPanel do not use up this GDI objects ? | ||||||||
Tags | No tags attached. | ||||||||
Project | |||||||||
Type | |||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0000580) Mathieu Malaterre (developer) 2004-01-28 13:36 |
Hi there, I'm currently implementing a Java application that heavily uses vtkPanel components. Every time a new set of data is selected for viewing panels are removed and new instances (1-4) are created and displayed. I'm somewhat confused about the amount of memory a vtkPanel consumes and if the resources are properly released, so I did the following sample program based on the SimpleVTK application. Four vtkPanels are instantiated and displayed. By checking/unchecking the check box you can remove panels, respectively create new ones. To my surprise (well actually based on my work on that other application I expected this), my swap file (I'm using Windows XP) increases by 5 MB per new set of panels. The size of this memory leak is relative to the number of vtkPanels. So why is this application consuming so much memory and why aren't the resources released? I'm explicitely using VTKDelete() calls to the VTK objects, and I also try to remove the Renderer & RenderWindow themselves. I cannot rely on Java's Garbage Collection to eventually trigger the removal of graphics resources because the size of the displayed data in the original application is too huge to hold it twice in memory. Thanks, Mark ******************************** VtkMemoryTest.java ******************************** package vtkmemorytest; import vtk.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class VtkMemoryTest implements ItemListener { final int NR_OF_VIEWPORTS = 4; JFrame frame; JPanel viewportPanel; JPanel vis3dPanel; JCheckBox vis3dSwitch; SimpleVTK[] simplePanel = new SimpleVTK[NR_OF_VIEWPORTS]; public VtkMemoryTest() { buildGUI(); } public void buildGUI() { frame = new JFrame("VTK Memory Test"); viewportPanel = new JPanel(); viewportPanel.setSize(600, 600); viewportPanel.setLayout(new BorderLayout()); vis3dPanel = new JPanel(); vis3dPanel.setSize(500, 500); vis3dPanel.setLayout(new FlowLayout()); vis3dSwitch = new JCheckBox(); viewportPanel.add(vis3dPanel, BorderLayout.CENTER); viewportPanel.add(vis3dSwitch, BorderLayout.SOUTH); switch3DOn(); frame.getContentPane().add(viewportPanel); frame.pack(); frame.setVisible(true); vis3dSwitch.addItemListener(this); } public void switch3DOn() { vis3dSwitch.setSelected(true); for (int idx = 0; idx < NR_OF_VIEWPORTS; idx++) { simplePanel[idx] = new SimpleVTK(); simplePanel[idx].setSize(200, 200); simplePanel[idx].setVisible(true); vis3dPanel.add(simplePanel[idx]); } vis3dPanel.validate(); } public void switch3DOff() { vis3dSwitch.setSelected(false); vis3dPanel.removeAll(); vis3dPanel.validate(); for (int idx = 0; idx < NR_OF_VIEWPORTS; idx++) { simplePanel[idx].release(); simplePanel[idx] = null; } } public void itemStateChanged(ItemEvent event) { if (vis3dSwitch.isSelected()) switch3DOn(); else switch3DOff(); } public static void main(String[] args) { VtkMemoryTest vtkMemoryTest1 = new VtkMemoryTest(); } } ******************************** VtkMemoryTest.java ******************************** package vtkmemorytest; import java.awt.*; import java.awt.event.*; import javax.swing.*; import vtk.*; public class SimpleVTK extends JPanel { vtkPanel renWin; vtkPolyDataMapper coneMapper; vtkConeSource cone; vtkActor coneActor; static { System.loadLibrary("vtkCommonJava"); System.loadLibrary("vtkFilteringJava"); System.loadLibrary("vtkIOJava"); System.loadLibrary("vtkImagingJava"); System.loadLibrary("vtkGraphicsJava"); System.loadLibrary("vtkRenderingJava"); try { System.loadLibrary("vtkHybridJava"); } catch (Throwable e) { System.out.println("cannot load vtkHybrid, skipping..."); } } public SimpleVTK() { setLayout(new BorderLayout()); renWin = new vtkPanel(); cone = new vtkConeSource(); cone.SetResolution(8); coneMapper = new vtkPolyDataMapper(); coneMapper.SetInput(cone.GetOutput()); coneActor = new vtkActor(); coneActor.SetMapper(coneMapper); renWin.GetRenderer().AddActor(coneActor); add(renWin, BorderLayout.CENTER); } public void release() { renWin.GetRenderer().RemoveActor(coneActor); cone.VTKDelete(); cone = null; coneMapper.VTKDelete(); coneMapper = null; coneActor.VTKDelete(); coneActor = null; renWin.release(); } } ******************************** vtkPanel.java ******************************** ... added method: public void release() { Lock(); rw.RemoveRenderer(ren); ren.VTKDelete(); rw.VTKDelete(); UnLock(); } URL: http://vtk.org/pipermail/vtkusers/2004-January/021810.html [^] |
(0000585) Mathieu Malaterre (developer) 2004-01-30 12:12 |
Jeff, Can we close this bug, thanks to your patch of vtkJavaAwt.h ? http://vtk.org/pipermail/vtkusers/2004-January/021888.html [^] |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2011-06-16 13:11 | Zack Galbreath | Category | => (No Category) |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |