- GDI Objects
- Posted by Hari Emani on October 15th, 2003
Hi,
I have a memory leack problem with GDI Objects. Here is the situation:
I need to create thousands of PDFs. So I choose Win2PDF and
PowerBuilder/Java. After printing 9998 (and 2100 in Java) from a PB
component, the applications become instable. Again after a restart
(only application, not the OS) it works fine until the above numbers
are reached. When I checked the no of GDIs in the task manager it is
also equal to the numbers specified above. So I assume for each print
call, one GDI object is being created.
As most of us know after reaching a particular limit, the application
becomes instable.
Can any one give me a work around for this. One solution is to restart
the application programatically. Other than this, any other solutions
would be appreciated. Some thign like - releasing the GDI objects to
clear memory, etc.
Thanks in advance.
Sincerely,
Hari Emani
- Posted by Feng Yuan [MSFT] on October 16th, 2003
Download gdiobj from http://www.fengyuan.com/download.html. It can tell you
what type of GDI objects are being accumulated.
If you see a clear pattern, you can enumeate them using undocumented method
(tested on Win2K) and then delete them. But similar objects created by other
part of the system may be deleted too.
Find the leak and then fix it.
--
Feng Yuan (www.fengyuan.com)
This posting is provided "AS IS" with no warranties, and confers no rights.
- Posted by Hari Emani on October 16th, 2003
Thanks Feng. It is a great tool. You are a genius.
I saw different GDI objects have been created in different situations.
For Example, when I Printed from PB I saw Bitmap objects created and
when I printed From Java I saw Brush and Other GDI objects have been
created.
Now how do I delete these? Which function should I call or any program
like you mentioned to execute. I have no exp in Win32API calls. Please
advise.
I really appreciate your help.
Sincerely,
Hari Emani
- Posted by Feng Yuan [MSFT] on October 17th, 2003
Suppose there is a function F(), which does your printing, any new GDI
object still remaining after calling F() needs to be deleted.
Our problem is now how to find those GDI objects.
There are two ways to do that, first implement a way to enumerate all GDI
objects created by the current process. Find the difference before and after
calling function F(). The way to do this emumeration is undocumented and
subject to change. Read Chapter 3 of my book.
Another way is hook all GDI object creation calls and store all GDI objects
created during the call to function F() and check if there are still there
after the call. API hooking within the same process is not that hard. Read
Chapter 1 and Chapter 4 of my book.
You can find Chapter 1 through link on my website.
--
Feng Yuan (www.fengyuan.com)
This posting is provided "AS IS" with no warranties, and confers no rights.
- Posted by Hari Emani on October 17th, 2003
Thanks Feng, I will see what is that I can do. If I have any thign
furterh I will get back to you.
Sincerely,
Hari Emani