LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

no size or contents info for arrays allocated with malloc?

I have a lot of arrays that I allocate dynamically, something like

float *a;
a = malloc(x * sizeof(float));
...
free(a);

However, when I want to watch the contents of these arrays I have to show them programatically (with printf or in a table or whatever). It would be very convenient if I could watch these in the watch window.

Is that possible?

Also, is it possible to determine the size of an allocated block? When I use realloc() to make a large array smaller in a certain program I have the idea no memory is gained back. Is there a way to check the amount of allocated memory of an array *after* it has been allocated?

Erwin Timmerman
0 Kudos
Message 1 of 2
(3,102 Views)
Hello Erwin

This is possible. After the malloc, right click on the variable and select "View Variable Value" during debugging. You should be able to view the individual array elements.

CVI includes the CVIDynamicMemoryInfo() function to allow you to view the total dynamic memory allocated in your application. You can get multiple snapshots to track the state of your dynamic memory

Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
Message 2 of 2
(3,103 Views)