LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual memory - again.

My application uses dynamic memory in very extensive way. It allocates many
buffers for the data (up to 200MB). Memory blocks are correctly freed but
process
has still 150MB of virtual memory.
I've noticed that if I open and close any CVI window, process virtual
memory decreases to correct value (about 60 MB). So I wrote memFree
function.
Results are visible in attachment. What's going on?

void memFree(void)
{
int handle;
if ((handle = NewPanel (0, "", 10, 3000, 100, 100))>0)
DiscardPanel(handle);
}
Regards
Jaroslaw Przywieczerski






[Attachment memory.png, see below]


[See first answer for additional information]
0 Kudos
Message 1 of 4
(3,269 Views)
[Attachment(s) for question]
0 Kudos
Message 2 of 4
(3,269 Views)
Memory freeing and releasing memory back to the system are two different things. When you free a block of memory, you are usually freeing a hole of memory inside the contiguous memory space of your application. Therefore, it is not released back to the system. If you want to watch for memory leaks and check to see the actual memory being used, you can't do it by using a system memory monitor. Use the CVIDynamicMemoryInfo function to see this. As for why the NewPanel/DiscardPanel is releasing the memory back to the system, I'm not sure why that is. There is a great deal of allocation and freeing that gets done with these functions so I assume some of that is causing the memory block to get released back to the system.

Best Regards,

Chris Matthews
Measurement
Studio Support Manager
0 Kudos
Message 3 of 4
(3,269 Views)
I know all this differences and I'm sure that dynamic memory management in
application is correct.
Using NewPanel/DiscardPanel functions is rather expensive way of freeing
memory back to the system, so I'd like to make it simpler (200MB process
virtual memory cause worse system efficiency). Could you suggest any
function?

CVIDynamicMemoryInfo - I don't know this function and didn't find any
documentation for it.

Are there any other functions usefull for debugging CVI applications?

Regards
Jaroslaw Przywieczerski

U¿ytkownik Chris Matthews w wiadomooci do grup dyskusyjnych
napisa³:506500000005000000FA340000-993342863000@exchange.ni.com...
> Memory freeing and releasing memory back to the system are two
> different things. When
you free a block of memory, you are usually
> freeing a hole of memory inside the contiguous memory space of your
> application. Therefore, it is not released back to the system. If
> you want to watch for memory leaks and check to see the actual memory
> being used, you can't do it by using a system memory monitor. Use the
> CVIDynamicMemoryInfo function to see this. As for why the
> NewPanel/DiscardPanel is releasing the memory back to the system, I'm
> not sure why that is. There is a great deal of allocation and freeing
> that gets done with these functions so I assume some of that is
> causing the memory block to get released back to the system.
>
> Best Regards,
>
> Chris Matthews
> Measurement Studio Support Manager
0 Kudos
Message 4 of 4
(3,269 Views)