Getting EOutOfResources exception

  I have a delphi app using a TabbedNoteBook with 8 tabs in it. Upon adding the components of the last (8th) tab, I started getting the error "Error Creating Window" whenever I ran my application. When I debugged it I got an "EOutOfResources exception". What is happenning and how can I fix it?

  Shawn Halfpenny

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I have some programs with more than 8 tabs and all works fine. However I don't know what is on your tabs and which version of Delphi you use. I think so mayby you put on this tabs very big set of bitmaps or other, so please tell us more.

You can place your components on your tabs in runtime if you use big set of resources and you can then free resources after they not needed. You can play with this at the OnChange event.
aztecAuthor Commented:
Hello Mirek...
  Thanks for your comment. I am using Delphi v1.0. I don't think my problem is caused by too many bitmaps.. I only have 1 little image I show on each tab and another little green checkmark I have in the 'Enter' button on each tab. I do however have a lot of edit boxes - 60 of them and I still have to add a couple more. I think this might be causing my problem, because all was going well until I added this my 8th tab which had 11 edit boxes in it.

From my program's code, here are ll the components I am using and the procedure headers that manipulate these components (do you think there may be too many?:

TForm1 = class(TForm)
    TabbedNotebook1: TTabbedNotebook;
    Label1: TLabel;
    Label2: TLabel;
    Edit3: TEdit;
    Label3: TLabel;
    Edit4: TEdit;
    BitBtn2: TBitBtn;
    Panel1: TPanel;
    Label4: TLabel;
    Label5: TLabel;
    Edit5: TEdit;
    BitBtn3: TBitBtn;
    Panel2: TPanel;
    Label6: TLabel;
    Label7: TLabel;
    Edit1: TEdit;
    Label8: TLabel;
    Edit2: TEdit;
    BitBtn4: TBitBtn;
    Panel3: TPanel;
    Label9: TLabel;
    Label10: TLabel;
    Edit6: TEdit;
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    CheckBox5: TCheckBox;
    CheckBox6: TCheckBox;
    Edit7: TEdit;
    Edit8: TEdit;
    Edit9: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    BitBtn1: TBitBtn;
    Panel4: TPanel;
    Label11: TLabel;
    Label12: TLabel;
    Edit12: TEdit;
    Label13: TLabel;
    Edit13: TEdit;
    Edit14: TEdit;
    Edit15: TEdit;
    Edit16: TEdit;
    Edit17: TEdit;
    Panel5: TPanel;
    BitBtn5: TBitBtn;
    Edit18: TEdit;
    Edit19: TEdit;
    Edit20: TEdit;
    Edit21: TEdit;
    Edit22: TEdit;
    Label14: TLabel;
    Label15: TLabel;
    CheckBox32: TCheckBox;
    CheckBox33: TCheckBox;
    CheckBox34: TCheckBox;
    Panel6: TPanel;
    Edit23: TEdit;
    Edit24: TEdit;
    Edit25: TEdit;
    Edit26: TEdit;
    Edit27: TEdit;
    Edit28: TEdit;
    Edit29: TEdit;
    Edit30: TEdit;
    Edit31: TEdit;
    Edit32: TEdit;
    BitBtn6: TBitBtn;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Image6: TImage;
    Button1: TButton;
    OpenDialog1: TOpenDialog;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Label16: TLabel;
    Button5: TButton;
    Button6: TButton;
    Label17: TLabel;
    Button7: TButton;
    Button8: TButton;
    Button9: TButton;
    Button10: TButton;
    Button11: TButton;
    Button12: TButton;
    Button13: TButton;
    Button14: TButton;
    Button15: TButton;
    Button16: TButton;
    MainMenu1: TMainMenu;
    FileMenu: TMenuItem;
    FileExit: TMenuItem;
    AdminMenu: TMenuItem;
    AdminRegister: TMenuItem;
    AdminPreview: TMenuItem;
    AdminBar1: TMenuItem;
    AdminShowStatus: TMenuItem;
    AdminShowCodes: TMenuItem;
    AdminShowPricing: TMenuItem;
    AdminShowLicense: TMenuItem;
    AdminShowPCId: TMenuItem;
    AdminBar2: TMenuItem;
    AdminCheckVersion: TMenuItem;
    Label22: TLabel;
    CheckBox7: TCheckBox;
    CheckBox8: TCheckBox;
    CheckBox9: TCheckBox;
    Label23: TLabel;
    Label24: TLabel;
    Edit33: TEdit;
    Button17: TButton;
    BitBtn7: TBitBtn;
    Panel7: TPanel;
    Image7: TImage;
    Label25: TLabel;
    Label26: TLabel;
    Edit34: TEdit;
    Button18: TButton;
    Label27: TLabel;
    Edit35: TEdit;
    Edit36: TEdit;
    Edit37: TEdit;
    Edit38: TEdit;
    Edit39: TEdit;
    Edit40: TEdit;
    Edit41: TEdit;
    Edit42: TEdit;
    Edit43: TEdit;
    Edit44: TEdit;
    BitBtn8: TBitBtn;
    Image8: TImage;
    Panel8: TPanel;
    Label28: TLabel;
    Edit45: TEdit;
    Panel9: TPanel;
    Panel10: TPanel;
    Panel11: TPanel;
    Panel12: TPanel;
    Panel13: TPanel;
    Panel14: TPanel;
    Panel15: TPanel;
    CheckBox10: TCheckBox;
    CheckBox11: TCheckBox;
    Edit46: TEdit;
    Edit47: TEdit;
    Edit48: TEdit;
    Edit49: TEdit;
    Edit50: TEdit;
    Edit51: TEdit;
    Edit52: TEdit;
    Edit53: TEdit;
    Edit54: TEdit;
    Edit55: TEdit;
    Label29: TLabel;
    Label30: TLabel;
    Button19: TButton;
    Button20: TButton;
    Button21: TButton;
    Button22: TButton;
    Button23: TButton;
    Button24: TButton;
    Button25: TButton;
    Button26: TButton;
    Button27: TButton;
    Button28: TButton;
    Image9: TImage;
    Panel16: TPanel;
    BitBtn9: TBitBtn;
    Edit56: TEdit;
    Edit57: TEdit;
    Edit58: TEdit;
    Edit59: TEdit;
    Edit60: TEdit;
    Label18: TLabel;
    CheckBox12: TCheckBox;
    CheckBox13: TCheckBox;
    CheckBox14: TCheckBox;
    CheckBox15: TCheckBox;
    CheckBox16: TCheckBox;
    CheckBox17: TCheckBox;
    CheckBox18: TCheckBox;
    CheckBox19: TCheckBox;
    CheckBox20: TCheckBox;

    procedure FormCreate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure remover_input(Sender: TObject);
    procedure remover_remove(Sender: TObject);
    procedure Edit5Change(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure Edit1Change(Sender: TObject);
    procedure Edit2Change(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure Edit6Change(Sender: TObject);
    procedure Edit7Change(Sender: TObject);
    procedure Edit8Change(Sender: TObject);
    procedure Edit9Change(Sender: TObject);
    procedure Edit10Change(Sender: TObject);
    procedure Edit11Change(Sender: TObject);
    procedure Edit12Change(Sender: TObject);
    procedure Edit13Change(Sender: TObject);
    procedure Edit14Change(Sender: TObject);
    procedure Edit15Change(Sender: TObject);
    procedure Edit16Change(Sender: TObject);
    procedure Edit17Change(Sender: TObject);
    procedure Edit18Change(Sender: TObject);
    procedure Edit19Change(Sender: TObject);
    procedure Edit20Change(Sender: TObject);
    procedure Edit21Change(Sender: TObject);
    procedure Edit22Change(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure CheckBox32Click(Sender: TObject);
    procedure CheckBox33Click(Sender: TObject);
    procedure CheckBox34Click(Sender: TObject);
    procedure Edit23Change(Sender: TObject);
    procedure Edit24Change(Sender: TObject);
    procedure Edit25Change(Sender: TObject);
    procedure Edit26Change(Sender: TObject);
    procedure Edit27Change(Sender: TObject);
    procedure Edit28Change(Sender: TObject);
    procedure Edit29Change(Sender: TObject);
    procedure Edit30Change(Sender: TObject);
    procedure Edit31Change(Sender: TObject);
    procedure Edit32Change(Sender: TObject);
    procedure BitBtn6Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
    procedure Button5Click(Sender: TObject);
    procedure Button6Click(Sender: TObject);
    procedure Button7Click(Sender: TObject);
    procedure Button8Click(Sender: TObject);
    procedure Button9Click(Sender: TObject);
    procedure Button10Click(Sender: TObject);
    procedure Button11Click(Sender: TObject);
    procedure Button12Click(Sender: TObject);
    procedure Button13Click(Sender: TObject);
    procedure Button14Click(Sender: TObject);
    procedure Button15Click(Sender: TObject);
    procedure Button16Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure AdminMenuClick(Sender: TObject);
    procedure AdminRegisterClick(Sender: TObject);
    procedure AdminPreviewClick(Sender: TObject);
    procedure AdminShowStatusClick(Sender: TObject);
    procedure AdminShowCodesClick(Sender: TObject);
    procedure AdminShowPricingClick(Sender: TObject);
    procedure AdminShowLicenseClick(Sender: TObject);
    procedure AdminShowPCIdClick(Sender: TObject);
    procedure AdminCheckVersionClick(Sender: TObject);
    procedure FileExitClick(Sender: TObject);
    procedure Button17Click(Sender: TObject);
    procedure BitBtn7Click(Sender: TObject);
    procedure Edit33Change(Sender: TObject);
    procedure Edit34Change(Sender: TObject);
    procedure Button18Click(Sender: TObject);
    procedure BitBtn8Click(Sender: TObject);
    procedure Edit45Change(Sender: TObject);
    procedure TabbedNotebook1Click(Sender: TObject);
    procedure Edit35Change(Sender: TObject);
    procedure Edit36Change(Sender: TObject);
    procedure Edit37Change(Sender: TObject);
    procedure Edit38Change(Sender: TObject);
    procedure Edit39Change(Sender: TObject);
    procedure Edit40Change(Sender: TObject);
    procedure Edit41Change(Sender: TObject);
    procedure Edit42Change(Sender: TObject);
    procedure Edit43Change(Sender: TObject);
    procedure Edit44Change(Sender: TObject);
    procedure CheckBox10Click(Sender: TObject);
    procedure CheckBox11Click(Sender: TObject);
    procedure Button19Click(Sender: TObject);
    procedure Button20Click(Sender: TObject);
    procedure Button21Click(Sender: TObject);
    procedure Button22Click(Sender: TObject);
    procedure Button23Click(Sender: TObject);
    procedure Button24Click(Sender: TObject);
    procedure Button25Click(Sender: TObject);
    procedure Button26Click(Sender: TObject);
    procedure Button27Click(Sender: TObject);
    procedure Button28Click(Sender: TObject);
    procedure Edit46Change(Sender: TObject);
    procedure Edit47Change(Sender: TObject);
    procedure Edit48Change(Sender: TObject);
    procedure Edit49Change(Sender: TObject);
    procedure Edit50Change(Sender: TObject);
    procedure Edit51Change(Sender: TObject);
    procedure Edit52Change(Sender: TObject);
    procedure Edit53Change(Sender: TObject);
    procedure Edit54Change(Sender: TObject);
    procedure Edit55Change(Sender: TObject);
    procedure BitBtn9Click(Sender: TObject);
    procedure Edit56Change(Sender: TObject);
    procedure Edit57Change(Sender: TObject);
    procedure Edit58Change(Sender: TObject);
    procedure Edit59Change(Sender: TObject);
    procedure Edit60Change(Sender: TObject);

.. Thanks for your assistance!

   Shawn Halfpenny

I create form with TabbedNotebook (8tabs). I place this set of components :

40xTBitBtn with glyphs
16xTImage with 300kbBitmap assigned to every one

The System and User Resources after running the program is 56% (before 90%).
I have 32MB RAM so it is possible that this is the problem, however I see so You have OnCreate assigned to form and I think that you must have some mistake in your code.
I have shareware program for testing loosed pointers and resources. I send this to you so please check your program.
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

aztecAuthor Commented:
Hi Mirek...
  Thanks for the additional comment. I have 32 megs of RAM too, so I don't think that is the problem. You are probably right though, that I have a mistake in my code .I will scan it thoroughly. You can e-mail me that shareware program, I appreciate it!

   Shawn Halfpenny
I send this program some hour ago ! If you don't receive this than please submit comment. You must compile program with detailed info and run the debug program. In this program set your program for debug and then run your program. You will see the use of resources and when you close your program you will have the list of errors in your program with line numbers. Delphi have some bugs so you will see some not dealocated pointers in VCL. I correct this in my VCL and you can do this in your too, however VCL leaves only some memory not dealocated.
aztecAuthor Commented:
Hello Mirek and all...
   This problem is driving me bananas! I seem to have isolated it down to the addition of just 1 edit box which is causing. I removed my 8th tab all together and was still getting the error, so I started paring away component by component on my 7th tab. I deleted 3 of 12 edit boxes I had on that tab - the error still occurred. Then I deleted 1 more error! Very strange. I ran that MemMonD thing but I don't understand it. Here are the reports from 2 MemMonD runs: one when I was getting the error (having deleted 3 of 12 edit boxes), and one when I was not getting the error (having deleted one more edit box):

MemMondD results (... getting error):

Windows resources at program start:
User      69 % free
GDI      79 % free

Windows resources at program termination:
User      69 % free
GDI      78 % free

Windows resources at lowest point:
User      61 % free
GDI      75 % free

Pointers not freed:
Bytes      Allocated at
12      (Graphics.FreeMemoryContexts + 1766)
12      (Graphics.FreeMemoryContexts + 1F7D)
12      (Graphics.FreeMemoryContexts + 1F94)
12      (Graphics.FreeMemoryContexts + 1FAB)
12      (Graphics.FreeMemoryContexts + 1FC2)
12      (Graphics.FreeMemoryContexts + 1FD9)
12      (Graphics.FreeMemoryContexts + 1FFF)
516      (Menus.TextToShortCut + 1AF3)
20      (Menus.TextToShortCut + 1B0A)
12      (Controls.DragMouseMsg + 5CAE)
12      (Forms.GetParentForm + 489B)
16      (Classes.LineStart + 046D)
16      (Classes.LineStart + 046D)
16      (Classes.LineStart + 046D)
32      (Classes.LineStart + 046D)
32      (Classes.LineStart + 046D)
320      (Classes.LineStart + 046D)
12      (Classes.DisposeStrItem + 0040)
12      (Classes.DisposeStrItem + 3568)
12      (Classes.DisposeStrItem + 3596)
16      (SysUtils.NewStr + 002B)
24      (SysUtils.NewStr + 002B)
24      (SysUtils.NewStr + 002B)
24      (SysUtils.NewStr + 002B)
24      (SysUtils.NewStr + 002B)
8      (SysUtils.StrAlloc + 0010)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
16      (System.FSafeDivideR + 1AD3)
16      (System.FSafeDivideR + 1AD3)
20      (System.FSafeDivideR + 1AD3)
28      (System.FSafeDivideR + 1AD3)

Highest global memory use:      86420 bytes
Highest stack memory use:      13072 bytes

End of report

MemMonD results ( error):
Windows resources at program start:
User      80 % free
GDI      87 % free

Windows resources at program termination:
User      80 % free
GDI      87 % free

Windows resources at lowest point:
User      73 % free
GDI      84 % free

Pointers not freed:
Bytes      Allocated at
12      (Graphics.FreeMemoryContexts + 1766)
12      (Graphics.FreeMemoryContexts + 1F7D)
12      (Graphics.FreeMemoryContexts + 1F94)
12      (Graphics.FreeMemoryContexts + 1FAB)
12      (Graphics.FreeMemoryContexts + 1FC2)
12      (Graphics.FreeMemoryContexts + 1FD9)
12      (Graphics.FreeMemoryContexts + 1FFF)
516      (Menus.TextToShortCut + 1AF3)
20      (Menus.TextToShortCut + 1B0A)
12      (Controls.DragMouseMsg + 5CAE)
12      (Forms.GetParentForm + 489B)
16      (Classes.LineStart + 046D)
16      (Classes.LineStart + 046D)
16      (Classes.LineStart + 046D)
32      (Classes.LineStart + 046D)
32      (Classes.LineStart + 046D)
320      (Classes.LineStart + 046D)
12      (Classes.DisposeStrItem + 0040)
12      (Classes.DisposeStrItem + 3568)
12      (Classes.DisposeStrItem + 3596)
16      (SysUtils.NewStr + 002B)
8      (SysUtils.StrAlloc + 0010)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
12      (System.FSafeDivideR + 1AD3)
16      (System.FSafeDivideR + 1AD3)
16      (System.FSafeDivideR + 1AD3)
20      (System.FSafeDivideR + 1AD3)
28      (System.FSafeDivideR + 1AD3)

Highest global memory use:      86140 bytes
Highest stack memory use:      13072 bytes

End of report

.. Hope you can help..I really have to get this program finished!

   Shawn Halfpenny
Mail to me source and wait some hours.
Windows version ?
aztecAuthor Commented:
Hello Mirek and all..
   I have been doing some surfing on the web searhing for a solution to this problem and came across a few possible solutions. It appears others have been getting this problem too and it results from having too many TEdit boxes and Windows does not have enough resources to allocate handles to them all. Some people have apparently written custom TEdit components to get around this problem but I cannot get my hands on these components. Please check out the following web pages to see what I mean:
   (.. do a search for "TNLEdit" on this page)
   ( a search for "FLYDEMO.ZIP" on this page)

Hope this helps!
   Shawn Halfpenny

I will try this pages but you run the MemMond and your max use of resoureces was :

User 61 % free
GDI 75 % free

I can correct this to you but please send me your source. You must be in any trivial mistake. I have working example with more TEdit and other. If you can't send me the source please create new project with this components and try. You really must have any mistake with your source. This is not problem of the big set of components.
Under the Options part of your project, do you create all forms automatically, or only the main form?  The problem may have nothing to do with your tabbed dialog, but that may simply be the straw that breaks the cammel's back.  

For ALL of my forms except the main form and the DataModule, I do something like this in each module:

Procedure Dlg_MyFomr;
      Application.CreateForm(TFM_MyForm, FM_MyFomr);
      FM_MyForm.ShowModal;  // form's processing
aztecAuthor Commented:
Hello Cashew...
   Thanks for your input, but I only have 1 form (Form1 created automatically, I guess), with a Tabbed Notebook of 8 tabs. I don't think this could be my problem, plus I don't understand the code you gave in your comment or where I'd implement it!

   Shawn Halfpenny
To others - the problem was in stack overflow.
I think so Delphi need report this error when the stack checking is enabled. However i try this and nothing happened - this is mistake of borland, however now it is solved.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aztecAuthor Commented:
Mirek is MOST helpful!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.