Using vtkChartXY realtime Memory leak

Hi all!

I hope all doing right, i have a question concerning vtkChartXY.

Im trying to use vtkChartXY to create a realtime plot, when i mean realtime is to plot samples in the grid, and at render time, erase all and replot the new arriving data.

My problem is exactly in this plot | erase | plot loop, im having Memory leak. Honestly, im not sure if its a problem of VTK 9.3, or ChartXY is not the right tool for a realtime approach, or my env for using QQuickVTKItem in QT.

Im open to answer any question or if someone has any idea, its well received.

Thanks :slight_smile:

Could you please share the memory leak information and a code snippet? A small reproducible example would be ideal.

Sure!
I dont think that its reproducible cause is a quite complex architecture code but this is the idea of what im doing.

VTK-Supp.cpp (8.6 KB)

The code has the .h and .cpp in the same file that i shared. The main idea is in the code, im filling tables to be plotted, being cleared and readded in the vtkChartXY.

And about the memory leak, i have open the Task Manager and if the QQuickVtkItem its opened the memory of the pc go up and up until the memory its full and the application crashes haha.

Thanks

Without a minimal standalone example that reproduces your problem we have no chance of guessing what is wrong.

You can determine the class of the leaked objects if you build your code with the CMake variable VTK_DEBUG_LEAKS set to ON. You can then add logs or breakpoints to determine which exact objects are not deleted and why. You can also ask a few different LLMs to inspect your code to see if they can find the root cause (suggest them to add logs if they cannot figure it out just by reading the code).

I totally understand, but to make this code work i need to run 3 others applications, sending data by UDP, thats why i try to resume the issue.

I was hoping to find maybe someone with a similar problem. Basically im using VTK 9.3 and QT with QML. Basically this is the pipeline:

  • UDP receives data
  • Send it to a buffer
  • The Coordinator of the rendering ask for data in a FPS rate
  • Send its to the CrossProfile2D (the file shared)

The CrossProfile inherits from QQuickVtkItem, and the render coordinator will call the ‘item-scheduleRender()’ at the FPS rate.

The main issue is there, even is there no data flowing and just the vtkChartXY its visible, like the grid lines, in the Task Manager i can see how the memory climbs at the FPS rate.

I have already ask a few LLMs but even then are lost, they told me that vtkChartXY is not for realtime plots.

I understand that to find the issue you will need to replicate the problem, but as i said, the architecture diagram its huge and replicate it need at least 3 different applications.

I can close the post if it is mandatory

Thanks anyways