I am working on a circular buffer implementation, and in the early phases of testing my approach I noticed something puzzling. I am trying to store LOTS of data in the buffer. I was using a hard disk circular buffering scheme with files, but I want to give the HDD a break, so I'm trying to do it with RAM.
The problem is that I cannot seem to get less than 3 data copies of the entire buffer. I could sort of understand how there may be two, but I'm trying to do everything as in-place as possible. Even when I show the buffer allocations, I can only see two black dots associated with the buffer (a 2D array of SGL).
It get's weirder....
I am looking at the Memory Usage page of the VI Properties dialog. If I initialize my buffer with a 1,000 x 1,000 array of SGL, I would expect roughly 4 MB for each copy of the array. Depending on the presence of a local variable, I can get close to 12 MB or close to 16 MB. That means that there are either 3 or 4 copies of the buffer floating around. What really gets me is that the local variable actually results in the 3 copy version! When I add a read local variable as the initializer to the shift register, there are 3 data copies of the buffer based on the memory.
I have attached the VI. If anyone can explain what's going on or suggest an alternative approach to the buffer, I'm all ears.... er eyes. The function runs extra fast when put in subroutine priority. Speed is not the big issue here, but memory footprint is.
Thanks,
Dan Press
PrimeTest Corp.
www.primetest.com