LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LAB Windows 2013 exe stops running after few hours

Hello everyone,

 

I have created an executable in labwindows to read and write to multiple ovens. The ovens are connected to the CPU ports through RS232. The executable works fine for about 10 hours and then it stops working saying the oven could not be initialized. 

Can anybody please help me with this problem?

 

0 Kudos
Message 1 of 6
(2,445 Views)

Programs that stop working after hours (or weeks!) are often due to memory mismanagement. In other words there's some 'free()' calls missing. See if your memory footprint goes up with time.

Message 2 of 6
(2,402 Views)

Yes indeed there is malloc() in a function in the code. I am having some trouble with dynamic memory allocation.

I want to use malloc() only once in the beginning of the code. Then inside a function I want to clear the pointer data and reuse the same pointer again..How do I do this?

I tried to use free() after malloc() in the function but the memory footprint still increases.

0 Kudos
Message 3 of 6
(2,391 Views)

Well, you have to spend some time to learn about memory allocation in C and do some training exercises, there's really no way around it (unless you want to hire a contractor to work on your code !). It's nothing to do with CVI, it's just the way C works.

0 Kudos
Message 4 of 6
(2,384 Views)

free () effectively freees up the memory allocated by malloc () so if you see the memory footprint increasing you may have some memory allocation more elsewhere in your program that you are not freeing. Keep in mind that some CVI functions allocate internal memory that must be freed with appropriate commands.

You may be trying to enable resource tracking by setting extended debugging level in Build options windows and run your code for a while: at program termination the IDE will show you where you have memory areas not freed, if any, as well as any other resource not properly disposed of.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 5 of 6
(2,380 Views)

Thank you so much for your reply. 

I checked with resource tracking in Labwindows.I am sure I am freeing after all malloc() . I think the memory leak is coming from a dll which I have not written and I don't have access to. Is there any way where I can restart the code after every few hours(through the code)..which would clear the memory??

0 Kudos
Message 6 of 6
(2,368 Views)