Any questions from a PROFI to a SUPER PROFI - 1. - page 29

 
sergeev:

when closing a handle, isn't the memory (which has been allocated over and above that specified in CreateFileMapping) not reverted back?
It's freed up. But it's at the end. We need to save memory at runtime.
 
at the end of what? the end of the win dow or the closing of a handful or the closing of an application?
 
sergeev:
at the end of what? the end of the win dow or the closing of a handful or the closing of an application?
Either one to choose from. Still, it's the end.
 
ah, well, if it's closing the header, then I don't think there's any memory leakage, it's the normal way for the Windows to free up memory when a header is deleted
 

It is somehow wrong to free memory while running by closing the descriptor.

The memory should be freed without the hope of Windos.

 
:) how else could it be freed? everything you've allocated, you've deleted. MSDN for Mapping does not say anything about manually freeing memory before closing the handler
 
sergeev:
:) how else could it be freed? everything you've allocated, you've deleted. MSDN for Mapping does not say anything about manually freeing memory before closing the handler
Well, I don't mean after closing handle. While working with memory we need to dynamically resize it. But you don't have to do it all the time. Constant reallocation takes time.
 

Vadim, what exactly are we parsing?

I found two ways to expand the memory. Do you think there will be problems with memory leaks in both cases?

 

If all descriptors are closed, there are no leaks. Leakage is when a program is unloaded but leaves resources occupied.

But there may be problems with excessive memory consumption. I had such problems myself not so long ago. I connected wrong class for working with timeseries. I added a class that indexes ticks by seconds. Started using this class to work with monthly bars. It ate all the memory in 30 seconds. This is one of the possible variants. We should monitor this kind of things and warn about them.

The second case is when the program needs a lot of memory, for instance, 1000 Mb, but not for a long time. If you don't free it, the other programs will have 1000 MB less until your program is unloaded.

In short, you need to keep track of resource consumption.

 
OK. I'll take that into consideration.