jgcode Posted November 2, 2010 Report Share Posted November 2, 2010 [LV2009] [Cross-posted to ni.com] I have found that if I pass a large data array (~4MB in this example) into an X-Control, it causes massive memory allocations (1 GB+). Is this a known issue? The X-Control in the video was created, then the Data.ctl was changed to 2D Array - it has not been edited in any other way. I also compare the allocations to that of a native 2D Array (which is only ~4MB). Note: I jiggled the Windows Task Manager about so that JING would update correctly, its a bit slow, but it essentially just keeps rolling up and doesn't stop. Demo code attached. Related to this thread by separated as posted to NI for support. Cheers -JG <object id="scPlayer" class="embeddedObject" width="921" height="858" type="application/x-shockwave-flash" data="http://content.screencast.com/users/jgcode/folders/LabVIEW/media/1bfce9bd-6cea-4622-ad26-8da61f63adc7/jingswfplayer.swf"> <param name="movie" value="http://content.screencast.com/users/jgcode/folders/LabVIEW/media/1bfce9bd-6cea-4622-ad26-8da61f63adc7/jingswfplayer.swf"> <param name="quality" value="high"> <param name="bgcolor" value="#FFFFFF"> <param name="flashVars" value="thumb=http://content.screencast.com/users/jgcode/folders/LabVIEW/media/1bfce9bd-6cea-4622-ad26-8da61f63adc7/FirstFrame.jpg&containerwidth=921&containerheight=858&content=http://content.screencast.com/users/jgcode/folders/LabVIEW/media/1bfce9bd-6cea-4622-ad26-8da61f63adc7/X-Control%20Memory%20Leak%20Demo.swf&blurover=false"> <param name="allowFullScreen" value="true"> <param name="scale" value="showall"> <param name="allowScriptAccess" value="always"> <param name="base" value="http://content.screencast.com/users/jgcode/folders/LabVIEW/media/1bfce9bd-6cea-4622-ad26-8da61f63adc7/"> Unable to display content. Adobe Flash is required. </object> X Control Bug LV2009.zip Quote Link to comment
Olivier Jourdan Posted November 2, 2010 Report Share Posted November 2, 2010 Hello JG, This memory leak is really frightening! Using LV2010 gives the same behavior.I've came across memory leaks on XControl. I've pointed issue in the undo/redo mechanism. I've tried to apply workaround used to fixed my issue on your example. It was unsuccessful.I've played few minutes with your example. I've noticed the following (maybe you've already note): Replace "millisecond multiple" constant by a control Execute your code Change the value from 1 to 100 On my PC, when update speed is less than 50, memory increase. When it's more than 50, memory decrease and stay to the same amount. There is something strange, if it was a "simple" memory leak the memory shouldn't decrease. I think we need the lights of NI engineers. 1 Quote Link to comment
Jeffrey Habets Posted November 2, 2010 Report Share Posted November 2, 2010 On my PC, when update speed is less than 50, memory increase. When it's more than 50, memory decrease and stay to the same amount. There is something strange, if it was a "simple" memory leak the memory shouldn't decrease. I think we need the lights of NI engineers. Seems something is being Queued up there.. 1 Quote Link to comment
Antoine Chalons Posted November 2, 2010 Report Share Posted November 2, 2010 Seems something is being Queued up there.. It really does! Last week I was helping a customer to solve speed issue with an X-Control, activating the "synchronous display" option solved the issue. 1 Quote Link to comment
jgcode Posted November 2, 2010 Author Report Share Posted November 2, 2010 Seems something is being Queued up there.. Hey Guys! Thanks heaps for the testing and feedback, much appreciated. Here are some more of my observations from further testing that tie in with yours - so I think this is starting to make sense! Using a smaller array (1 element instead of 100) as the element of the buffer, the issue went away I also made some changes that sped up the X-Control (e.g. update graph by explicit reference in subVI to implicit reference on facade) which also helped with the above If I smash the X-Control (fast, as per the demo) and hit the stop button, the VI stops but the X-Control continues updating for what can be a while. So yes, I am inclined to believe the data is being queued somewhere -> because it can't keep up, and hence this is the cause of the allocationsThe concerning thing is: my application (whilst doing other things in parallel) was only updating the X-Control every 1000ms and was still causing a 1-2+MB/s leak!This X-Control could, instead of queuing if it ran late, just ignore data and catch up (given I am not buffering anything inside it) - but that is out of my control.For the design I initially wanted to define the interface as a '2D Array of DBL's' (the buffer). So to allow if I want to user the buffer for something else.Maybe I will have to look at something else. Ideas:I could buffer the data inside the X-Control so the behavior is like a Chart not a Graph - so the interface just becomes a '1D Array of DBL's'? Or I could reference an external buffer (i.e. using a DVR)? - but didn't want to do that. Thoughts? Cheers -JG <edit>Tried toggling Synchronous Display but it did not help the allocations, thanks for suggestion tho</edit> 1 Quote Link to comment
jgcode Posted December 1, 2010 Author Report Share Posted December 1, 2010 Damn - got stung by this one again, each time data (class) was passed to the X-Control's Property Node interface, a 2MB allocation occurred. I pulled the code out of the X-Control (it was classes, so it wasn't that hard to do), ran the code on a VI with standard LabVIEW controls (XY graph, ring etc...) - memory leak fixed! Quote Link to comment
SuperS_5 Posted December 16, 2010 Report Share Posted December 16, 2010 Hi, I stumbled on this and experimented a little bit. The exact execution of the loop that causes the queing seams to be base upon CPU saturation. If I do something that uses up a lot of cycles compounds the queing issue. It seams that the xnode is getting a lower execution priority, not matter what I selected in the VI properties. Even the smallest amount shortage of CPU cycles in the user interface thread causes the issue. In the referring post you mentioned that you have a CAR for this issue. Any response from NI? Quote Link to comment
jgcode Posted December 16, 2010 Author Report Share Posted December 16, 2010 In the referring post you mentioned that you have a CAR for this issue. Any response from NI? Hi SuperS_5 The issue is with R&D however, I followed up with NI AE to get the actual CAR Number - #257325. I have been chasing it up periodically over the last 6 weeks, but there is nothing new to post. (I have no clue really) but I don't imagine there would be a simple fix? Also, I am hoping that an X-Control polish will be part of the 2011 stability release. That would be sweet. Quote Link to comment
SuperS_5 Posted December 16, 2010 Report Share Posted December 16, 2010 Stability is always nice. I guess for now we have to be careful in the way we deal with x-nodes. Quote Link to comment
SuperS_5 Posted December 19, 2010 Report Share Posted December 19, 2010 (edited) Hi again. I was looking at a some other code, and had a light bulb moment. If you update a stack instead of the x-node, and call the x-node, which reads from that stack, allows more control over the queuing. Of course this means a lot more coding, but at least no memory leak if done correctly. Although I am only guessing, I think the x-node is called by the UI thread. This method, allows for the stack to run in a separate thread, with its own priority. When used in your example, I had no memory leak, while using a free running loop to update the x-node and stack. Edit: I forgot to add that you would call the x-node using some other data. I used an empty array, but, theoretically any data could be used. The x-node data-type could even be something totally different. Edited December 19, 2010 by SuperS_5 Quote Link to comment
jgcode Posted December 19, 2010 Author Report Share Posted December 19, 2010 Or I could reference an external buffer (i.e. using a DVR)? - but didn't want to do that. I was looking at a some other code, and had a light bulb moment. If you update a stack instead of the x-node, Are you talking about something similar to my suggestion above? Are you able to go into more detail? Quote Link to comment
SuperS_5 Posted December 19, 2010 Report Share Posted December 19, 2010 I guess I missed that post. I didn't get the "DVR" part. (The first meaning that I think of is Digital Video Recorder, but I know that I am just confused Past job experience.) I suppose its the same, but I was thinking a simple vi with an unregistered shift register. I would put all of the "real time" data processing code there instead of the x-control. That way the X-control would just pull it out of the "buffer." I guess it wasn't such a light bulb moment after all. PS. I just realized that I used x-node above, where I meant x-control. Quote Link to comment
jgcode Posted December 19, 2010 Author Report Share Posted December 19, 2010 I guess I missed that post. I didn't get the "DVR" part. (The first meaning that I think of is Digital Video Recorder, but I know that I am just confused Past job experience.) I suppose its the same, but I was thinking a simple vi with an unregistered shift register. I would put all of the "real time" data processing code there instead of the x-control. That way the X-control would just pull it out of the "buffer." I guess it wasn't such a light bulb moment after all. PS. I just realized that I used x-node above, where I meant x-control. DVR = Data Value Reference Quote Link to comment
SuperS_5 Posted December 19, 2010 Report Share Posted December 19, 2010 DVR = Data Value Reference I had to look that up. My method would be a memory hog, but, still without a memory leak. The DVR method would be more efficient, and essentially the same external functionality, but with more programming. PS. That link did not work, but I did find other NI pages on it. Thanks for the translation.:thumbup1:lol Quote Link to comment
jgcode Posted December 19, 2010 Author Report Share Posted December 19, 2010 PS. That link did not work, but I did find other NI pages on it. Thanks for the translation.:thumbup1:lol Judging by other thread, NI might have been down? - URL works for me now tho. Quote Link to comment
Olivier Jourdan Posted December 20, 2010 Report Share Posted December 20, 2010 Or I could reference an external buffer (i.e. using a DVR)? - but didn't want to do that. Hello JG Reading again this thread, I notice that this workaround have a lack. You'll lose the recording mechanism integrated in the facade.vi. if you never write "Data". This can be really annoying if you want to distribute your XControl. It won't behave as the user expect to. We really need a bug fix from NI Regards 1 Quote Link to comment
jgcode Posted December 20, 2010 Author Report Share Posted December 20, 2010 Hello JG Reading again this thread, I notice that this workaround have a lack. You'll lose the recording mechanism integrated in the facade.vi. if you never write "Data". This can be really annoying if you want to distribute your XControl. It won't behave as the user expect to. We really need a bug fix from NI Regards I like your persistence! I just prodded the support engineer again just then. Quote Link to comment
SuperS_5 Posted December 20, 2010 Report Share Posted December 20, 2010 I totally agree that a work-around is not a fix, but temporary solution. Thanks for prodding. Quote Link to comment
jgcode Posted December 21, 2010 Author Report Share Posted December 21, 2010 Hey Guys LabVIEW R&D has responded in cross-post, jump across to the darkside if you want to chime in. Cheers -JG 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.