Click here to Skip to main content
15,915,600 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Detecting ALT-Left-Mouse-DblClk event? Pin
Jason Hooper20-Jul-02 11:52
Jason Hooper20-Jul-02 11:52 
GeneralRe: Detecting ALT-Left-Mouse-DblClk event? Pin
JennyP20-Jul-02 11:56
JennyP20-Jul-02 11:56 
Generalstd::strstream Pin
User 988520-Jul-02 9:18
User 988520-Jul-02 9:18 
GeneralRe: std::strstream Pin
Rama Krishna Vavilala20-Jul-02 12:02
Rama Krishna Vavilala20-Jul-02 12:02 
GeneralRe: std::strstream Pin
Todd Smith23-Jul-02 13:29
Todd Smith23-Jul-02 13:29 
GeneralDLL Problem !!! Plz help Pin
jancsi20-Jul-02 8:26
jancsi20-Jul-02 8:26 
GeneralRe: DLL Problem !!! Plz help Pin
Dudi Avramov21-Jul-02 1:33
Dudi Avramov21-Jul-02 1:33 
GeneralRe: DLL Problem !!! Plz help Pin
Daniel Lohmann21-Jul-02 1:53
Daniel Lohmann21-Jul-02 1:53 
Dudi Avramov wrote:
Correct me if i am wrong:
someone creates a list object , sends it to your dll and you fail to delete that object.
If that so, then check whether your run-time library and the caller run-time library are the same.
For example, if your run-time library is Multithread Dll (/MD) and the caller run-time library is Multithread (/Mt).
Check what happens when the caller's project and your project have the same run-time library.


Uh, oh - this works only if both the .dll and the .exe use the same DLL-Version of the CRT. It will fail if they are linked against the static version.
The reason is the following: The CRT contains a heap manager, which implements operators new and delete. If you link the CRT statically to a module (.exe or .dll) the heap manager is also linked to your module, meaning that each module contains its own heap manager. It is not possible to allocate memory from one heap manager and delete it with another one - they don't know of each other and the memory just looks invalid to them. And this is what happens in your project.

However, if both, the .dll and the .exe are linked to the same DLL-Version of CRT, they share the same heap manager (because the CRT DLL is loaded only once into the process' address space). Then all ressources (memory, open file handles, etc.) are interchangeable between the modules.

To avoid this messy details it is common and good practise to destroy resources always in the same module they have been allocated. Then the used CRT version does not matter and you are always on the safe side Smile | :)




--

Daniel Lohmann

http://www.losoft.de
GeneralMFC project on XP - wont work! Pin
ns20-Jul-02 7:48
ns20-Jul-02 7:48 
GeneralRe: MFC project on XP - wont work! Pin
Chris Losinger20-Jul-02 8:26
professionalChris Losinger20-Jul-02 8:26 
GeneralRe: MFC project on XP - wont work! Pin
ns20-Jul-02 8:32
ns20-Jul-02 8:32 
GeneralRe: MFC project on XP - wont work! Pin
Chris Losinger20-Jul-02 8:34
professionalChris Losinger20-Jul-02 8:34 
GeneralRe: MFC project on XP - Rebuild All resolved it! Pin
ns22-Jul-02 3:50
ns22-Jul-02 3:50 
GeneralRe: MFC project on XP - wont work! Pin
Alexandru Savescu21-Jul-02 9:08
Alexandru Savescu21-Jul-02 9:08 
GeneralVC.net and Distribution issues Pin
Sumudu Perera20-Jul-02 7:10
Sumudu Perera20-Jul-02 7:10 
GeneralRe: VC.net and Distribution issues Pin
Chris Losinger20-Jul-02 8:28
professionalChris Losinger20-Jul-02 8:28 
GeneralAppendMenu problem ! Pin
Hadi Rezaee20-Jul-02 6:59
Hadi Rezaee20-Jul-02 6:59 
GeneralRe: AppendMenu problem ! Pin
Chris Losinger20-Jul-02 8:29
professionalChris Losinger20-Jul-02 8:29 
GeneralRe: AppendMenu problem ! Pin
Hadi Rezaee20-Jul-02 16:54
Hadi Rezaee20-Jul-02 16:54 
GeneralGood C++ book... Pin
merlin987620-Jul-02 6:00
merlin987620-Jul-02 6:00 
GeneralRe: Good C++ book... Pin
Stan Shannon20-Jul-02 6:17
Stan Shannon20-Jul-02 6:17 
GeneralRe: Good C++ book... Pin
valikac20-Jul-02 6:17
valikac20-Jul-02 6:17 
GeneralRe: Good C++ book... Pin
Ken Mazaika20-Jul-02 7:30
Ken Mazaika20-Jul-02 7:30 
GeneralRe: Good C++ book... Pin
Christian Graus20-Jul-02 12:55
protectorChristian Graus20-Jul-02 12:55 
Generalpassing COM into another COM Pin
Anonymous20-Jul-02 5:16
Anonymous20-Jul-02 5:16 

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.