On Wed, 6 Apr 2022 02:48:58 -0700 (PDT), Ravindra Panchal wrote:
same issue with my app. Have you got any clue on this memory leak, how to resolve ?
On Thursday, July 11, 2002 at 6:13:37 PM UTC+5:30, Stephen Kellett wrote:
In message <[email protected]>, baskar
<[email protected]> writes
Hi,
Using the following code to access the shared memory.
*****************************************
Object *dcM;
dcM = (Object *) MapViewOfFile(hMapFile, // Handle to mapping object. >>>FILE_MAP_ALL_ACCESS, // Read/write permission
0, // Max. object size.
0, // Size of hFile.
0); // Map entire file.
dcM[0].method1() //Memory leak occors here >>>*****************************************
Memory leak is occuring while calling method1. Need I to do anything to >>>handle this.
It's not a memory leak. It's how mapped memory work.
The system does not initially allocate any memory. Only the address space.
The system will dynamically allocate memory (in pages) as data is read/write from/to it. So, the more data is read/write from/to different part of the mapped memory, the more memory would actually be allocated. If all parts of
the mapped memory is read, the system would end up allocating memory as
large as the entire source of the mapped memory. IOTW, the system would only allocate memory as needed, and won't deallocate them until the mapped memory
is destroyed.
Mapped memory works similar to NTFS Sparse files in terms of storage space allocation. e.g. if a new 10MB sparse file is created without writing
anything into it, it won't consume any storage space. It'll only consume storage space (in clusters) when a data is actually written into it. e.g. if the NTFS cluster size is 4K, and 1K data is written at start and at end of
the file, the file would only consume 8K of storage space.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)