LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Graph control and bitmap: out of memory and screen flicker

Hi,

 

I use a old version of CVI to develop the application. I use graph to display a kind of image movement. So First I have a loop to use 

PlotBitmap to display and DiscardBitmap to release the memory for each PlotBitmap, still I got out of memory error after a while and finnally crash the system. Then I combine PlotBitmap(with null file name) and SetCtrlBitmap, then the screen start to flicker (the ATTR_REFRESH_GRAPH is set to 0 and call RefreshGraph to refresh manually, the strange thing is that with only PlotBitmap, it doesn't flicker)

 

thanks,

 

Eric 

0 Kudos
Message 1 of 3
(3,437 Views)

Hi Eric,

 

The likely reason that you are seeing a memory leak is that you need to delete the reference to the plot before the last image was added.  Each time you plot an image, a new plot is created in your control, so we need to use the DeleteGraphPlot function to clear the old reference.  This can be accomplished using something like this:

 

oldPlotHandle = PlotBitmap (panelHandle, PANEL_GRAPH1, x, y, width, height, fileName[]);  
loop
    {    

    DeleteGraphPlot(panelHandel,PANEL_GRAPH1,oldPlotHandle,VAL_DELAYED_DRAW)
    oldPlotHandle = PlotBitmap (panelHandle, PANEL_GRAPH1, x, y, width, height, fileName[]);
    }

 

You shouldnt need to use DiscardBitMap(), since PlotBitmap does not create an image ID, only a plot handle.  hope this helps!

Al B.
Staff Software Engineer - TestStand
CTA/CLD
0 Kudos
Message 2 of 3
(3,404 Views)

Hi AI,

 

thank you for your reply.

 

Actually since the beginning the function DeleteGraphPlot is called to delete all plots for each loop (with the plothandle -1, besides plotbitmap, application also plot point and text). After application runs a while, it starts return -12 for function PlotBitmap from time to time. After checking the forum here, I decided to add DiscardBitmap() function. Any other suggestion?

 

Eric

0 Kudos
Message 3 of 3
(3,390 Views)