Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Memory Leak problem while using MapViewOfFile

130 views
Skip to first unread message

baskar

unread,
Jul 11, 2002, 6:31:23 AM7/11/02
to
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.


Regards,
Baskar

Stephen Kellett

unread,
Jul 11, 2002, 8:43:37 AM7/11/02
to
In message <b5a71bcf.02071...@posting.google.com>, baskar
<cbas...@yahoo.co.in> writes

People usually want to fix their memory leaks.

A good tool for identifying and fixing memory leaks is Memory Validator.
A 30 day evaluation can be found at http://www.softwareverify.com

Regards

Stephen
--
Stephen Kellett http://www.objmedia.demon.co.uk
Object Media Limited C++/Java/Windows NT/Unix/X Windows/Multimedia
If you are suffering from RSI, contact me for advice.
Unsolicited email from spam merchants not welcome.

Ravindra Panchal

unread,
Apr 6, 2022, 5:48:59 AM4/6/22
to
same issue with my app. Have you got any clue on this memory leak, how to resolve ?

JJ

unread,
Apr 6, 2022, 11:15:42 AM4/6/22
to
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 <b5a71bcf.02071...@posting.google.com>, baskar
>> <cbas...@yahoo.co.in> 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.
0 new messages