Solved

EOutOfResources problem

Posted on 1998-01-15
11
273 Views
Last Modified: 2010-04-04
I write a very large application (a lot of forms, all created at the beginning). When the application reached a certain size, I got an EOutOfResources exception.

One of the dominant side effects is that when the application is running, from some point it refuses to open windows, does not show pop-up menus or parts of them.

at the help they say it is because too much handles are in use, but I tried solutions that would work if this is the reason, and they didn't work. Furthermore , I wrote an application that opens hundreds of forms,buttons .. without
any error .
I work on a computer with 200MB Ram , so memory is not the
problem.

anyway , i would like to know , what are the various reasons
to get the EOutOfResources exception , and how can i trap resource leak (NT 4.0 environment  ) ?

Thanks , Ori.
0
Comment
Question by:oris
11 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1356687
Are all your forms loaded when the project is loaded?
If yes, Then load only the neccessary forms for the current operation.
When you close a form do you call Release?
If not, then on the form close event you should call Release;
Did you verify that none neccessary objects are freed?
Use Numega to locate memory leaks.

Ronit,
Kfar Saba

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1356688
about memory leaks :

There are some commercial programs on the net for finding such leaks.
But, I found one, which is freeware and is good, you can find it at  : http://home.sprynet.com/sprynet/rrm/. It calls snoop.

If you can't find it, i can send it to you

Good luck!
Regards,
ZifNab.
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1356689
Ronit...I thougth you are from Israel!

Me too, I'm from Petach-Tiqa...

Matvey
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 5

Expert Comment

by:JimBob091197
ID: 1356690
What ver of Delphi?
0
 
LVL 5

Expert Comment

by:inter
ID: 1356691
Causes
------
EOutofResources error is reported by the Windows whenever a handle is to be created or new class is to be registered to the system. Any handle creation function (DC, menu,window-form) returns 0 and Delphi interpret this as a OutofResources error.
By my opinion this is not correct, or one step more is needed to understand the actual error.The delphi should call GetLastError, but it does not.
When I search this error in VCL source code I found that it is in the following units:  Graphics, Forms, Menus.

Limits
------
Windows 95 is limitted to 16384 handles per object class, i.e. this much of menu or window locks up the system. However Windows NT does not have a restriction on number of handles.


Suggestions
-----------
Asside from the other friends suggestions I have the following:
1 - If you are creating several TCanvas, TPen, TBrush, TMetafile etc.(in general memory consuming GDI objects), be sure to call Free for them.
2 - As a rule of thumb do not precreate more than 20 such resources on FormCreate.
3 - Remember that out of resources error is cummulative. i.e. it may not appear at the begining; by forgetting to release handles the system resources may be used up gradualy.
4 - If you sure that you free the handles allocated by your program (manualy by calling constructors of TCanvas, TPen etc), try to maintain the list of handles manualy created by
program and FREE them ALL in ExitProc or finalization section. Because when your program terminated erronously some of the Free methods may not be called
5 - If you are making use of large bitmaps just for painting the background of forms etc. Create bitmap, paint it and release it if you are not doing time critical painting (animation).

GOOD LUCK!
0
 

Author Comment

by:oris
ID: 1356692
I'd like to add some details:
- I'm working on Delphi 2.0
- I tried BoundsChecker and it gave me only information about minor memory/resource leaks
- The NT task manager says that I'm using no more than 1400 handles at a time.
- The failure happens even if I shutdown the computer and then execute the application (there are no remains of executions from the past), before I have the chance to use any exit routines.
- My application is a large MDI application. Dozens of forms are created in the dpr file as MDI childs.
- There are almost no dynamic creations in the FormCreates. I do use Free.
- I would like to emphasize that I suspect Pop-up menus and commands like ShowMessage or MessageDlg, which create new windows.

thanks.
0
 
LVL 5

Expert Comment

by:inter
ID: 1356693
oris,
-I am still working on it but could not find menu or window related cause for your problem.
-However, (probably you know these but) there are two things to remind. First of all there is a patch of System.pas which fixes a 32 bytp memory leak in allocation. It is directly available from
http://www.borland.com/devsupport/delphi/downloads/index.html
-And while I try to determine the cause of the problem, I have found that suspended TThread (classes.pas) instance keeps the program from terminating. But, I still use Delphi 2.00, this problem may be fixed in 2.01.
-Also, there is a component called SNOOP for detecting memory leaks etc from http://sunsite.icm.edu.pl/delphi/ zipped into snoop110.zip

Please, write comments, I really interested the problem, the EXPERT points are not important.

Regards,
Igor

0
 

Author Comment

by:oris
ID: 1356694
I solved the problem by using less handles.
Igor, I'd like to give you the points, but I can't do that until you submit another answer.

thanks.
0
 
LVL 5

Expert Comment

by:inter
ID: 1356695
Thank you very much oris,
However, to gain that much points I'd like to do more for you. Tell me if I can help in Delphi or windows stuff (component-utility etc.)
Thanks again,
Igor
0
 

Author Comment

by:oris
ID: 1356696
Igor,
I really don't need anything, and I do not expect anything. If you think you got really cool stuff, with no regard to my question, you are welcomed to send it to me. My email is
oris@math.tau.ac.il.

thanks. (please submit an answer).
0
 
LVL 5

Accepted Solution

by:
inter earned 400 total points
ID: 1356697
Thanks friend,

Have a nice programming.

Igor (inter@kosgeb.tekmer.gov.tr)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question