seoul Posted December 12, 2005 Report Share Posted December 12, 2005 my program can not run a long time, cause it use memory more and more. only "index array" "replace array subset" "build array" "enqueue element" "dequeue element" in my diagram wich one i mentioned above cost too much memory? how can i control the usage of memory?:headbang: thank you! :worship: Quote Link to comment
Götz Becker Posted December 12, 2005 Report Share Posted December 12, 2005 "build array" and "enqueue element" are adding memory... control those and you should be fine. My common mistake or bad programming habit is to use "build array" in a loop to gather values. With small test data all works well, when running with real data things often get large and slow. Another thing hit me once when using queues. I split some work in two threads with a queue in between, classic producer/consumer. classic mistake i made... consumer was much slower and the producer kept enqueueing stuff (it worked for a night until windows rejected to allocate more memory) . Now I always double check if I set a value for the maximum amount of elements when creating stuff with queues and that the producer waits if queue is full. Another thing I had to learn the hard way, is to often use the "Show Buffer Allocations"-Tool. Perhaps you could give a little more detail what the program does. Hope this helps (and feel to correct me if something is wrong) Quote Link to comment
seoul Posted December 12, 2005 Author Report Share Posted December 12, 2005 just as you said, i use queue to transfer data between different threads in which arrays are used to gather calculated values. The function of this thread is calculating the data indexed from the array transfered by the first queue, then build these calculated values into a new array. After that, put the new array into another queue. i think i have to use queue and array to realize this function. But how to limit the usage of memory? "build array" and "enqueue element" are adding memory... control those and you should be fine.My common mistake or bad programming habit is to use "build array" in a loop to gather values. With small test data all works well, when running with real data things often get large and slow. Another thing hit me once when using queues. I split some work in two threads with a queue in between, classic producer/consumer. classic mistake i made... consumer was much slower and the producer kept enqueueing stuff (it worked for a night until windows rejected to allocate more memory) . Now I always double check if I set a value for the maximum amount of elements when creating stuff with queues and that the producer waits if queue is full. Another thing I had to learn the hard way, is to often use the "Show Buffer Allocations"-Tool. Perhaps you could give a little more detail what the program does. Hope this helps (and feel to correct me if something is wrong) Quote Link to comment
FLX Posted December 12, 2005 Report Share Posted December 12, 2005 Hi, try the national instruments tutorial http://zone.ni.com/devzone/conceptd.nsf/we...6256E58005D9712 good day alex Quote Link to comment
Goose Posted December 13, 2005 Report Share Posted December 13, 2005 Instead of using build array, use the initalize array function and just insert elements into the array. this will keep memory use constent. Another thing is if you are using any express VI's in your program, Well I found that most of the time they cause memory leaks. I try to avoid these types but do use them from time to time to get me started. Quote Link to comment
Khalid Posted December 13, 2005 Report Share Posted December 13, 2005 NI's Application Note # 168 on LabVIEW Performance and Memory Management is a good one too: http://zone.ni.com/devzone/conceptd.nsf/we...6256A37005541D3 -Khalid 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.