LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CIN memory problem

Hi,
I need to call inside a while loop the attached CIN code (thread_cin.c) which allocates large amounts of memory (calloc function must be used), build one array, passes it to labview application (thread_cin.vi) and then frees the memory.
I notice that at every iteration more memory is used (task manager can be used to see it) and then the vi crashes.
This does not happen if the C application is built and run as stand alone (not as CIN).
This means that, as CIN, memory is not released at every while iteration like in common C stand alone applications.
May someone help me indicating how to solve the problem?
Thanks,
Pier
Download All
0 Kudos
Message 1 of 3
(2,660 Views)
out:
>>>>>>>>> return err;

free(RxData_tot); // free memory
free(colore); // free memory
free(scan); // free memory

Your function never reaches the memory free functions as it returns before that with the err code. Removing that return altogether seems like a very good idea to me.

By the way it is not a very good idea to return anything else than noErr from CINRun(). This will immediately abort the entire application. It would be better to just return the error in an extra error variable and deal with the error in traditional ways through error clusters for instance.
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 3
(2,660 Views)
You are 100% right!
Thank you,
Pier
0 Kudos
Message 3 of 3
(2,660 Views)