vtkWin32OpenGLRenderWindow resize (memory leak)?

HI Paulo, I am not suggesting that the bug is necessarily in VTK. It is quite reasonable that the problem lies somewhere else. I need to find where. However my graphics card drivers are the latest:
I will try to test the issue on all machines I can find. I have already tested it on another PC with a different AMD graphics card model. On this machine I also tested it without the mesa 3D dll, the output is the same. Since the Mayavi code does not have the problem I am hesitant to blame the graphic driver, although I don’t know exactly what the code does.
Thanks for your suggestions.

1 Like

We encountered not the same, but a similar problem where memory leaks happened whilst resizing a window (see the issue here https://gitlab.kitware.com/paraview/paraview/-/issues/20430).

We never found a solution though. Note that this was on a Linux machine.

Interesting Thomas, thanks. It seems very close to what I am experiencing. In the meantime I managed to find the VTK binaries for the Mayavi library. While linking these binaries I am still getting the memory leak. I also tested my application on three other machines with different Graphic card. Therefore now I am thinking that there may be something wrong in my Visual Studio 2019 project configuration.
In my configuration I just include a vtkModuleAutoInit.h file which contains this define:

#define vtkRenderingCore_AUTOINIT 1(vtkRenderingOpenGL2)

As I understand it, this allows for OpenGL2 implementation of the vtkRenderWindow (class vtkWin32OpenGLRenderWindow).
My concern is that this might not be enough and something is missing in my configuration.
I coud not find much information about compiling with Visual Studio.

I changed the vtkModuleAutoInit.h file to:

#define vtkRenderingCore_AUTOINIT 2(vtkRenderingOpenGL2,vtkInteractionStyle)
#define vtkRenderingContext2D_AUTOINIT 1(vtkRenderingContextOpenGL2)

I got rid of a warning I had: warning: link to vtkInteractionstyle for default style selection.
But still no luck with the memory leak.

I’ve found the cause of the memory leak. First of all I changed the Auto init configuration to:

#define vtkRenderingOpenGL2_AUTOINIT 1(vtkRenderingGL2PSOpenGL2)
#define vtkRenderingCore_AUTOINIT 3(vtkInteractionStyle,vtkRenderingFreeType,vtkRenderingOpenGL2)
#define vtkRenderingVolume_AUTOINIT 1(vtkRenderingVolumeOpenGL2)

This new configuration forced the linking of other two libraries:


I added these other dlls to the output:


After these changes and after reading here:
paragraph: What Graphics Cards work with VTK

I tested the program on my local machine without mesa 3D and the memory leak disappeared! As I understand it, the mesa 3D library substitutes the OpenGL of the Graphics card. Still working on remote desktop I need mesa 3D and the problem remains.

In summary:

  • VTK has no bug
  • My code had a wrong configuration (but I must understand better what these autoinit defines do)
  • Mesa 3D is the cause of the memory leak.

Thanks to Paulo for supporting me.

That’s ok. It’s a process of eliminating hypotheses. We had to rule out driver.

I say thank you. You did all the detective work to spot that. I confess I’d never suspect of Mesa, since it’s been around since 1993 with input of industrial contributors. It would be a good idea to check which Mesa API version is supported by your system, but I don’t know how to do that in Windows (as all things Microsoft). Latest version is 20.something.

Edit: Often the graphics driver installs an utility that can be used to check Mesa version. You can also try the dxdiag command in a prompt, but it didn’t show any info on Mesa for me.

Hi Paulo, I downloaded the mesa that I am using. It’s a Windows compiled version taken from here GitHub - pal1000/mesa-dist-win: Pre-built mesa software rasterizer drivers for Windows it’s version 20.2.2. I see that it is not official by the way. Reading more about it, it seems that Mesa 3d shouldn’t really be necessary on Windows. After reading here (paragraph 6) https://www.amd.com/system/files/documents/remote-workstation-user-guide.pdf I enable the mentioned services, rebooted but nothing changed. I don’t know why but on Remote Desktop my application works only with mesa 3d. Anyway I have found some memory issue even in mesa official release Massive memory leak (at least AMD, others unknown) (#3513) · Issues · Mesa / mesa · GitLab. One more thing: I checked again my results, the VTK auto_init configuration is not important as I thought. Even with the old configuration and linking, there is no memory leak (without mesa). I believed that I had already verified this before but I was probably wrong. Still it’s not clear to me how the Mayavi application even with the mesa 3D has no memory leak but it’s not really important now.

It’s odd that your app requires Mesa to work. Mesa is only an abstraction layer over 3D rendering backends (OpenGL, Direct 3D, Vulkan, etc.). In Windows, in the end you’re using either OpenGL or Direct3D anyway. It would be good to check which backend Mesa 3D is using in your case, since Windows supports both.