Click here to Skip to main content
15,904,416 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: about hook in dll Pin
Mike Beckerleg28-Apr-04 22:17
Mike Beckerleg28-Apr-04 22:17 
GeneralIMAP components Pin
Jeremy Pullicino28-Apr-04 3:03
Jeremy Pullicino28-Apr-04 3:03 
Generala c++ active control used in VB Pin
includeh1028-Apr-04 2:44
includeh1028-Apr-04 2:44 
GeneralRe: a c++ active control used in VB Pin
Cedric Moonen28-Apr-04 2:58
Cedric Moonen28-Apr-04 2:58 
GeneralASSERT(_crtIsvalidheappoint() )error, Help! Pin
orteaorme28-Apr-04 2:40
sussorteaorme28-Apr-04 2:40 
GeneralRe: ASSERT(_crtIsvalidheappoint() )error, Help! Pin
Mike Dimmick28-Apr-04 2:46
Mike Dimmick28-Apr-04 2:46 
GeneralRe: ASSERT(_crtIsvalidheappoint() )error, Help! Pin
orteaorme28-Apr-04 2:52
sussorteaorme28-Apr-04 2:52 
GeneralRe: ASSERT(_crtIsvalidheappoint() )error, Help! Pin
Mike Dimmick28-Apr-04 5:09
Mike Dimmick28-Apr-04 5:09 
Sorry, I should have read more thoroughly. You shouldn't have one binary in the same process linked to the static version of the C runtime library and another linked to the DLL version. If more than one binary uses the C runtime, they should all use the DLL version.

One of many reasons is that the C runtime creates a new operating system heap (using the HeapCreate function) during CRT startup, for all allocations made using the C or C++ runtime libraries. Each instance of the CRT (a statically-linked copy of the CRT counts as a new instance) creates its own heap. See HEAPINIT.C in the CRT source code.

You can't allocate from one heap but free from another. The effect of your code is that the code from a::a (and hence the memory allocation from new) runs in the context of the code running new a (in this case, your executable), but the memory deallocation runs from the module containing a's destructor (the DLL). delete therefore tries to free the memory from the wrong heap, leading to the assertion. In a Release build, you won't get the assertion, but you will get a memory leak.

The practical upshot of this is that you must either link all MFC-using components in the same process with the MFC DLL, or never create classes outside the DLL they're implemented in.

Stability. What an interesting concept. -- Chris Maunder
GeneralRe: ASSERT(_crtIsvalidheappoint() )error, Help! Pin
orteaorme28-Apr-04 17:27
sussorteaorme28-Apr-04 17:27 
GeneralRe: ASSERT(_crtIsvalidheappoint() )error, Help! Pin
Paul Ranson28-Apr-04 3:32
Paul Ranson28-Apr-04 3:32 
GeneralRe: ASSERT(_crtIsvalidheappoint() )error, Help! Pin
orteaorme28-Apr-04 17:29
sussorteaorme28-Apr-04 17:29 
Generalgeting font from hdc (GDI) in API way Pin
ravjak28-Apr-04 1:42
ravjak28-Apr-04 1:42 
GeneralRe: geting font from hdc (GDI) in API way Pin
Roger Allen28-Apr-04 1:46
Roger Allen28-Apr-04 1:46 
GeneralRe: geting font from hdc (GDI) in API way Pin
ravjak28-Apr-04 2:41
ravjak28-Apr-04 2:41 
GeneralRe: geting font from hdc (GDI) in API way Pin
Steve S28-Apr-04 1:47
Steve S28-Apr-04 1:47 
GeneralRe: geting font from hdc (GDI) in API way Pin
ravjak28-Apr-04 2:37
ravjak28-Apr-04 2:37 
GeneralFormat string function Pin
Anonymous28-Apr-04 1:29
Anonymous28-Apr-04 1:29 
GeneralRe: Format string function Pin
toxcct28-Apr-04 1:50
toxcct28-Apr-04 1:50 
GeneralRe: Format string function Pin
Anonymous28-Apr-04 2:07
Anonymous28-Apr-04 2:07 
GeneralRe: Format string function Pin
toxcct28-Apr-04 2:19
toxcct28-Apr-04 2:19 
GeneralRe: Format string function Pin
ravjak28-Apr-04 2:33
ravjak28-Apr-04 2:33 
GeneralHelp me, please Pin
Roozbeh6928-Apr-04 1:20
professionalRoozbeh6928-Apr-04 1:20 
GeneralIsConnected to internet Pin
Member 101882328-Apr-04 0:32
Member 101882328-Apr-04 0:32 
GeneralRe: IsConnected to internet Pin
Jitendra gangwar28-Apr-04 0:56
Jitendra gangwar28-Apr-04 0:56 
GeneralRe: IsConnected to internet Pin
Antti Keskinen28-Apr-04 1:00
Antti Keskinen28-Apr-04 1:00 

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.