05-04-2009 08:03 AM
Hello,
I have a little design question for you...
I have a server communicating periodically with several devices (1 to 30). The communication is made by TCP-IP and data is sent periodically (every 20 seconds for exemple, could be less or more).
Would it be better to keep my connections active all the time (for hours or days) or to close it and reopen a new connection each time I want to send some data?
Thanks in advance!
Vincent
Solved! Go to Solution.
05-04-2009 08:11 AM - edited 05-04-2009 08:14 AM
If the app is going to be up and running forever then I would design to open it once and keep it open. If you run into errors close the old and re-open a new connection. So keep the "opens" to a minimum.
If the app is just going to run for an hour or two, then its a toss-up.
Reasoning behind above:
Every time a resource is allocated in LV a small block of memory is resereved to handle the kernal modes (?) stuff. This block of memory is never release as long as LV is running. If you repeatedly open a ref, you will be slowly leaking memory. You can prove this to yourself by crating a VI that opens a closes a reference repeatedly in a loop and let it run over the week-end. If you note the memory useage before and after you should be able to meassure the leak. Over time it will eat all avaliable memory.
Just trying to help,
Ben
05-04-2009 08:37 AM
Thanks for your answer Ben!
My design was done that way (keeping my connection active). So I'm glad I won't have to change it.
It's also a good thing to know that memory allocated in LV will not be release until LV is closed (I must admit I'm a bit surprise here). I will keep that in mind for my future design as well...
Thanks a lot!
Vincent
05-04-2009 08:45 AM
vgravel wrote:Thanks for your answer Ben!
My design was done that way (keeping my connection active). So I'm glad I won't have to change it.
It's also a good thing to know that memory allocated in LV will not be release until LV is closed (I must admit I'm a bit surprise here). I will keep that in mind for my future design as well...
Thanks a lot!
Vincent
You are very welcome Vincent!
And that you for taking to time to mark that reply as the solution!
Ben