Smitty1276

I have a set of components in DLLs that I have to load and reload many times... unless necessary, I would prefer not to get bogged down by specifics about that; just know that I HAVE to LoadLibrary() then FreeLibrary() on those DLLs many times--mostly due to an annoying amount of static data that causes problems "resetting" things.

In any case... after several iterations of the load/unload cycle, they will fail to load with an error 8, "Not enough storage is available to process this command." This leads me to believe that the system isn't actually freeing the library. Is this true

Does anyone have any ideas what might cause this behavior How might I **FORCE** windows to actually free the library when I instruct it to do so by calling FreeLibrary



Re: Visual C++ General Repeated loading/unloading of libraries causes Error 8

Smitty1276

Aren't there microsoft software engineers on these forums Noone understands the internals of FreeLibrary Is this published somewhere

Also, I know that FreeLibrary unmaps the memory for the lib, but at what point is the system supposed to actually free the memory I would like to force it.




Re: Visual C++ General Repeated loading/unloading of libraries causes Error 8

scor7910

When you call a LoadLibrary, if library already loaded other application, increase reference counter.

Like LoadLibrary , When you call a FreeLibrary, if library already loaded other application, decrease reference counter.

I have no doubt about a FreeLibrary.

Check a memoty leaks plz...

And see a this web page.

http://www.microsoft.com/technet/prodtechnol/windows2000serv/reskit/w2000Msgs/3714.mspx mfr=true






Re: Visual C++ General Repeated loading/unloading of libraries causes Error 8

Smitty1276

I understand the internal reference counting... I'm talking about what FreeLibrary actually does. Because it is very, very clearly isn't actually making the memory available after the libs are freed. Everytime I reload the libraries the memory usage jumps by an enormous amount.

What I am asking, to reiterate yet again, is how do I make FreeLibrary actually make the memory available immediately I understand that Error 8 means I don't have enough memory. What I want to know is how to make Windows give me my memory back when I call free library.

I've checked, and my pointers are being deleted, so there shouldn't be 1.5GB of memory leaks after 8-10 reloads.




Re: Visual C++ General Repeated loading/unloading of libraries causes Error 8

scor7910

How about use a FreeLibraryAndExitThread function.

reference this page-> http://msdn2.microsoft.com/en-us/library/ms683153.aspx






Re: Visual C++ General Repeated loading/unloading of libraries causes Error 8

Smitty1276

Hmm... Would there be a way to use that without killing the process




Re: Visual C++ General Repeated loading/unloading of libraries causes Error 8

Simple Samples

Smitty1276 wrote:
I HAVE to LoadLibrary() then FreeLibrary() on those DLLs many times

You should solve that problem.

Note that LoadLibrary() is a Windows API function and therefore is outside the scope of this forum. It is possible that you are not getting more help for that reason. Or perhaps people here can't help more and the experts that can help more are in other forums and newsgroups.






Re: Visual C++ General Repeated loading/unloading of libraries causes Error 8

Simple Samples

Smitty1276 wrote:
What I want to know is how to make Windows give me my memory back when I call free library.

I've checked, and my pointers are being deleted, so there shouldn't be 1.5GB of memory leaks after 8-10 reloads.
Part of the problem could be fragmentation.