Jump to content

how to control the usage of memory


seoul

Recommended Posts

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:

Link to comment

"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)

Link to comment

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)

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.