title: System Error. Code: 8. Not enough storage is available to process this command
body: <p>We have a few Win32 applications (coded in Delphi 2006) where sometimes the user gets an error message saying <strong>"System Error. Code: 8. Not enough storage is available to process this command."</strong>.</p>
  
  <p>From the stacktrace it looks like it is always during CreateWnd call</p>
  
  <pre><code>Main ($1edc):
  004146cc +070 app.exe SysUtils               RaiseLastOSError
  00414655 +005 app.exe SysUtils               RaiseLastOSError
  004ce44c +130 app.exe Controls               TWinControl.CreateWnd
  00535a72 +022 app.exe cxControls             TcxControl.CreateWnd
  004ce82a +016 app.exe Controls               TWinControl.CreateHandle
  00553d21 +005 app.exe cxContainer            TcxContainer.CreateHandle
  00586ef1 +005 app.exe cxEdit                 TcxCustomEdit.CreateHandle
  005c331d +005 app.exe cxDropDownEdit         TcxCustomDropDownEdit.CreateHandle
  004ceaf0 +074 app.exe Controls               TWinControl.UpdateShowing
  004ceb1e +0a2 app.exe Controls               TWinControl.UpdateShowing
  004cebdc +03c app.exe Controls               TWinControl.UpdateControlState
  004d118a +026 app.exe Controls               TWinControl.CMVisibleChanged
  004cb713 +2bb app.exe Controls               TControl.WndProc
  004cf569 +499 app.exe Controls               TWinControl.WndProc
  004b727d +4c1 app.exe Forms                  TCustomForm.WndProc
  004cb3a0 +024 app.exe Controls               TControl.Perform
  004c9f6a +026 app.exe Controls               TControl.SetVisible
  004b6c46 +03a app.exe Forms                  TCustomForm.SetVisible
  004baf1b +007 app.exe Forms                  TCustomForm.Show
  004bb151 +14d app.exe Forms                  TCustomForm.ShowModal
  007869c7 +0d3 app.exe UfrmPrice      770 +19 TfrmPrice.EditPrice
  0078655d +009 app.exe UfrmPrice      628  +0 TfrmPrice.actNewBidExecute
  00431ce7 +00f app.exe Classes                TBasicAction.Execute
  004c2cb5 +031 app.exe ActnList               TContainedAction.Execute
  004c397c +050 app.exe ActnList               TCustomAction.Execute
  00431bb3 +013 app.exe Classes                TBasicActionLink.Execute
  004af384 +090 app.exe Menus                  TMenuItem.Click
  004b059f +013 app.exe Menus                  TMenu.DispatchCommand
  004b16fe +082 app.exe Menus                  TPopupList.WndProc
  004b164d +01d app.exe Menus                  TPopupList.MainWndProc
  004329a8 +014 app.exe Classes                StdWndProc
  7e4196b2 +00a USER32.dll                     DispatchMessageA
  004bea60 +0fc app.exe Forms                  TApplication.ProcessMessage
  004bea9a +00a app.exe Forms                  TApplication.HandleMessage
  004becba +096 app.exe Forms                  TApplication.Run
  008482c5 +215 app.exe AppName        129 +42 initialization
  </code></pre>
  
  <p>I've never been able to get to the bottom of what causes this and as it happens fairly seldom I haven't been to concerned, but I would like to find out what causes it and hopefully rectify it...</p>
  
  <p><strong>EDIT:</strong> Full Stacktrace</p>
  
  <p><strong>EDIT 2:</strong> More info... The client who experienced this today has had my app installed for about 4 months and it is running on his PC 8 hours a day. The problem only appeared today and kept reappearing even though he killed my app and restarted it. None of the other apps on his system behaved strangely. After a reboot the problem goes away completely. Does this point towards the heap shortage that Steve mentions?</p>
  
  <p><strong>EDIT 3:</strong> Interesting msdn blog post <a href="http://blogs.msdn.com/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx" rel="noreferrer">here</a> and <a href="http://blogs.msdn.com/ntdebugging/archive/2007/07/05/desktop-heap-part-2.aspx" rel="noreferrer">here</a> on the topic of the desktop heap. Though I'm not sure whether this is the cause of the problem it certainly looks likely.</p>