|
-
April 7th, 2004, 07:49 AM
#1
Loading DLL's at custom base address
I've got a funny situation in which a program runs out of memory too early. With too early I mean the malloc() and new() are failing because they can't allocate memory while there is still plenty.
The problem is that there is no big enough chunk of memory available. The app requests 300 meg, while there the largest chunk available is 250 f.i.
The cause of this memory "fragmentation" are a couple of DLL's with a bad base address. Most of these DLL's are shipped together with the application so I can use the REBASE tool to give them a sensible address.
But I've got one left... OPENGL32.DLL has a base address of 0x5ED0000 and is a system DLL so I can't modify this one.
I can of course copy this file, rebase it, and put it next to the executable.
But that's not what I want to do. Because this way I'll be missing out on updates (via service packs f.i.).
The "beautifull" way would be to "tell" the loader that it shouldn't use the base address but load it somewhere else.
In other words, I want to force a relocation of a DLL.
Has any of you done this before ?
-
April 7th, 2004, 10:37 AM
#2
Actually, I think you will have further DLLs on your customers computers which will cause trouble, not only OPENGL32.dll. PGP Plugins for example love to pop into your applications address space by some hook from system32.dll.
Thus I would recommend doing it the other way around: Convert your executable from an exe to a DLL. Afterwards, write a simple loader, which first allocates the 300M memory chunk and afterwards loads dynamically your "DLL" application. Thus all rebasing would be done by the operating system afterwards.
BTW: You should take a look at your programs memory consumption - 300 Meg in one large chunk - there must be something wrong with your applications design!?
The Saviour of the World is a Penguin and Linus Torvalds is his Prophet.
-
April 7th, 2004, 11:42 AM
#3
Re: Loading DLL's at custom base address
Originally posted by KarelBijl
The "beautifull" way would be to "tell" the loader that it shouldn't use the base address but load it somewhere else.
In other words, I want to force a relocation of a DLL.
Has any of you done this before ?
No. I haven't. Nor I tried to understand your problem. But just looking at this question, I beleive there is a way ( which of course I haven't tried at all )
If you are using VC++ IDE, in your project settings, go to Link tab, select category as Output. Here you have an option to specify the base address. You could try it. But probably this is not an option for you since you want to change the base address of OpenGL, right ?
-
April 7th, 2004, 03:25 PM
#4
There was a similar question about a month ago where the problem was difficulty allocating 300 MB. In that situation, the allocatin was being used for a very large image. Responses in that thread suggested redesigning the application.
300 MB is a huge amount of memory. There was a time when that amount of physical memory would be very expensive yet whatever you are doing, it was done then too. Hardware is so cheap compared to the recent past that it is certainly best to let it do the work instead of us but in this situation it is probably relatively easy to process the data without loading all of it into memory at once.
-
April 8th, 2004, 04:09 AM
#5
I agree that preventing the allocation of a 300 meg chunk sounds like the obvious solution.
But this not really an option. Actually the 300 meg in one go was introduced for speed improvements. Only on windows 32 bit I have this problem with DLL in the wrong place.
I've thought of claiming the base address of OPENGL32.dll .. I wonder where the loader will put it then.
-
April 8th, 2004, 09:09 AM
#6
Originally posted by KarelBijl
But this not really an option.
Sure it is.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|