Click here to Skip to main content
15,908,254 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Error not releasing memeory Pin
Chris Losinger18-May-06 5:10
professionalChris Losinger18-May-06 5:10 
JokeRe: Error not releasing memeory Pin
Roger Stoltz18-May-06 6:17
Roger Stoltz18-May-06 6:17 
GeneralRe: Error not releasing memeory Pin
ThatsAlok18-May-06 19:03
ThatsAlok18-May-06 19:03 
GeneralRe: Error not releasing memeory Pin
led mike18-May-06 5:49
led mike18-May-06 5:49 
GeneralRe: Error not releasing memeory Pin
ThatsAlok18-May-06 19:07
ThatsAlok18-May-06 19:07 
GeneralRe: Error not releasing memeory Pin
Cedric Moonen18-May-06 20:20
Cedric Moonen18-May-06 20:20 
GeneralRe: Error not releasing memeory Pin
led mike19-May-06 5:21
led mike19-May-06 5:21 
GeneralRe: Error not releasing memeory Pin
Cedric Moonen19-May-06 6:19
Cedric Moonen19-May-06 6:19 
led mike wrote:
There is one and only one default heap across an entire process.


Maybe heap manager was not the good term. Ok, they have the same heap but still, you cannot delete memory that hasn't been allocated by the same module:

Both the DLL and the executable file (EXE) maintain their own lists of allocated memory blocks, which they maintain through the malloc memory allocator. The C++ new and delete functions also rely on these lists of memory blocks, so that C++ tends to use dynamic memory allocation more often than C. If the DLL allocates some memory—for example, for the creation of a new instance of a class—this memory is marked in the allocation list of the DLL. If the EXE tries to free this memory, the run-time library looks through its list of allocated memory blocks and fails (usually with a GP fault). Thus, even if the memory between the DLL and the EXE is completely shared, the logic for managing allocation breaks if two modules mix their allocation schemes.

Reference[^]

And furthermore, something that is more relevant than hundred of articles: I experienced this problem. And it was solved by following this guideline: never free mem that has been allocate by your dll in your exe.

And, also, try it yourself, it will be the best proof: make a simple dll with a simple function that only allocate some memory (a char array for example) and return this pointer. Then, in your program, delete this memory. You'll see what happen Wink | ;)


Cédric Moonen
Software developer

Charting control
GeneralRe: Error not releasing memeory Pin
led mike19-May-06 7:26
led mike19-May-06 7:26 
GeneralRe: Error not releasing memeory Pin
Cedric Moonen21-May-06 22:24
Cedric Moonen21-May-06 22:24 
QuestionMultiple Line ToolTip Pin
Andy Rama18-May-06 4:14
Andy Rama18-May-06 4:14 
AnswerRe: Multiple Line ToolTip Pin
NiceNaidu18-May-06 5:12
NiceNaidu18-May-06 5:12 
GeneralRe: Multiple Line ToolTip Pin
Andy Rama18-May-06 5:45
Andy Rama18-May-06 5:45 
GeneralRe: Multiple Line ToolTip Pin
Andy Rama18-May-06 19:56
Andy Rama18-May-06 19:56 
Questionlib file Pin
big_denny_20018-May-06 4:02
big_denny_20018-May-06 4:02 
AnswerRe: lib file Pin
Cedric Moonen18-May-06 4:10
Cedric Moonen18-May-06 4:10 
GeneralRe: lib file Pin
big_denny_20018-May-06 6:28
big_denny_20018-May-06 6:28 
AnswerRe: lib file Pin
NiceNaidu18-May-06 4:32
NiceNaidu18-May-06 4:32 
GeneralRe: lib file Pin
Cedric Moonen18-May-06 4:41
Cedric Moonen18-May-06 4:41 
AnswerRe: lib file Pin
Eytukan18-May-06 4:34
Eytukan18-May-06 4:34 
GeneralRe: lib file Pin
Rage18-May-06 4:42
professionalRage18-May-06 4:42 
GeneralRe: lib file Pin
Cedric Moonen18-May-06 4:45
Cedric Moonen18-May-06 4:45 
GeneralRe: lib file Pin
NiceNaidu18-May-06 4:50
NiceNaidu18-May-06 4:50 
GeneralRe: lib file Pin
Eytukan18-May-06 4:54
Eytukan18-May-06 4:54 
AnswerRe: lib file Pin
Eytukan18-May-06 4:54
Eytukan18-May-06 4:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.