Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Void

Aren't Dlls the same as static libs??

This topic is 6930 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Besides the issues of linking and compiling, dlls should be similar to libs since they dlls are mapped to the process calling space and address.. so.. why is it when I write a wrapper around the C debug libs ( the _CrtDumpMemoryLeaks function, to be exact)and place them in dlls and static libraries, the dlls will not be able to catch memory leaks while the static libraries are able to (for the same program).. Is the dlls viewed as its own process by the C debug lib?? ..

Share this post


Link to post
Share on other sites
Advertisement
All I can think of is that static libraries really are PART of your program. They are basically obj files that you link in, and they''re part of the same module as the program. So they can catch allocation errors and leaks in their module. But a DLL, even if it''s mapped to the program''s memory, is still a seperate module, and really knows nothing about your program, so it can''t catch memory errors..

That''s just a guess though, I''m not sure

------------------------------
Jonathan Little
invader@hushmail.com
http://www.crosswinds.net/~uselessknowledge

Share this post


Link to post
Share on other sites
my thoughts too..

but since dlls have no exe main but dllmain and it is attached to the main program.. I would think the C debug lib would be able to differentiate..

Man.. I wish things like this are documented somewhere so we don''t have to waste time learning the hard way..

Share this post


Link to post
Share on other sites
As far as I know, C++ DLLs have the same heap as the main program (i.e., memory you allocate with new()). You can new() something in the DLL and delete() it in the program and vice versa. Same for malloc() and free(), if C DLLs have the same heap as the main program.

DLLs do have a different stack, but I don''t know why anyone would want to track memory allocation on the stack for a game...



- null_pointer
Sabre Multimedia

Share this post


Link to post
Share on other sites
What''s probably happening is that you''re statically linking the runtime libraries to both the dll and the executable. Debug memory allocations are logged in a _CrtMemState structure located in the CRT library. Because the dll and the executable are linked to separate copies of the CRT library, the allocations are being logged in the executable''s copy of the _CrtMemState structure and the dll is reporting from the dll''s copy of the _CrtMemState structure. So it''s not a problem of multiple heaps, it''s a problem of multiple logging structures.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!