01-12-2009 02:50 PM
nathand wrote:If you're not seeing a buffer allocation then one isn't taking place. Have you tried turning on the option (in preferences) to show constant folding? If you're using a simple test VI you may find that the build array is folded into a single constant array, so no buffer allocation is needed - but your real life case is probably more complex. I think you'll get the same results using either build array or reshape array, and both of them will cause a buffer allocation, according to this thread on LAVA (there's a question about reshape array towards the bottom of the first page, and I expect that build array is the same).
I just turning on the "show constant folding" option, and still it does not seem that any buffer is showing up withy a single 1D array on the input of the Build Array function. I read that thread on LAVA but am still a little confused. I could't tell from you post whether you think a buffer will be created in this situation. Is the Show Buffer Allocation tool the final authority or are you saying that even though it might say there is not buffer being created the circumstances may be complex and it will create one anyway when it is actually running the code. Thanks for your help![]()
01-13-2009 07:47 AM
I was just trying to say that if you're using a simple test VI to look at buffer allocations, make sure that it reflects the complexity of your actual application before making conclusions about where buffer allocations are occurring. You can trust the show buffer allocation tool. I was just making a guess, without seeing your code, and apparently I was wrong. I am curious, though - if you change your build array to reshape array, do you get a buffer allocation? If so, can you post that code (or an image of it)?
Be careful of spending too much time optimizing - have you spent some time profiling your code first to determine where the bottlenecks are? Do you know how many times you call the code that you're trying to optimize?
01-14-2009 08:02 AM
01-14-2009 08:12 AM
01-14-2009 08:19 AM
DFGray wrote:
Dequeuing an array does not make a copy of the array (at least for single-element queues) despite what the buffer viewer says. You can easily verify this yourself (see attached VI, LV8.6). In a VI, create a large data set, enqueue it into a single-element queue, dequeue and do something with it (e.g. extract an element using the in-place element), then requeue it. Now single-step through the VI with Task Manager active while watching the memory allocated to LabVIEW. Set your data set to something easy to see (e.g. 10MBytes). The only allocation will be the initial one. This is why single-element queues outperform action engines for arrays. It is all pointers.
Would it be fair to say, then, that if the buffer allocation tool does not show an allocation then it's definite that one does not occur, but even if it does show an allocation, it's possible that one is NOT occurring? Are there other cases where this would occur other than queues and similar by-reference types?
01-14-2009 08:23 AM
The code that I am trying to optimize is inside of a loop that will be executed alot of times and deals with alot of data, it seems like it might be good to optimize this bit.
DFGray: I wasnt able to open that VI, I have LV8.5. Would it be possible to post a 8.5 version?
01-14-2009 08:26 AM
01-14-2009 12:14 PM - edited 01-14-2009 12:16 PM
01-14-2009 12:32 PM - edited 01-14-2009 12:33 PM
Oh okay, thats why I couldnt edit it, it had been too long since the initial post. I thought I was going crazy because I editied one before but I couldnt find the edit option again. Thanks
01-15-2009 08:14 AM
I believe amaglio is correct, but cannot confirm it ( few people are here this early in the morning
). If the buffer viewer shows a copy, it is not necessarily a full copy. It may be only a pointer copy, especially if the underlying data object is something like an array or cluster (pointer based objects in C).
I have run into occasions where the buffer viewer did not report a copy when one existed. This usually happens at wire forks and on older versions of LabVIEW. The gold standard is the operating system memory monitor (Task Manager in Windows). If it matters, it is usually worth the time to single step through your code and validate the buffer viewer.