4

I'm developing a project in Delphi Rio 10.3 Community and it currently has 24 units. This particular form I'm having problems with contains 28 frames of the same type, each containing a TChart component with a few buttons and checkboxes (print chart, show/hide series/labels, etc.). Everything was fine until about 20-25 frames/charts, but yesterday I added a couple more till I reached 28. No errors whatsoever at design nor run-time, so I closed Delphi happily at the end of the day.

Problem started next time I started Delphi. The exact error I'm getting when I simply open my project is "Error creating form: Out of memory." After acknowledging the error the project still opens fine, except for this particular DFM file with 28 frames/charts. I can still compile and run the project without any issues, but I can't visualize the form in the IDE in order to develop it further.

I understand I reached some kind of limitation, although the project/form is not huge. I have an i7 with 32GB memory, Windows shows I have 26GB free, so I think that's plenty.

I didn't find any reference to this exact error message on the web, but some similar compiler error, which is not my case:

http://docwiki.embarcadero.com/RADStudio/Rio/en/F2046_Out_of_memory_(Delphi)

However, I did try the workaround with increasing the swap file size in Windows, but no luck.

I also installed the latest IDE Fix Pack 6.4.2 from Andy, again no success:

https://andy.jgknet.de/blog/ide-tools/ide-fix-pack/

DFM file has around 3000 lines, so pasting only one of the 28 frames/charts in it:

    inline FrameSmartChart1: TFrameSmartChart
      Left = 50
      Top = 800
      Width = 450
      Height = 250
      TabOrder = 2
      ExplicitLeft = 50
      ExplicitTop = 800
      inherited Chart1: TChart
        Title.Text.Strings = (
          'Incoming Calls From MSCs')
        PrintMargins = (
          15
          22
          15
          22)
        inherited Label0: TLabel
          Width = 52
          Hint = 'Voice-Charging-Originating-Call'
          Caption = 'Originating'
          ExplicitWidth = 52
        end
        inherited Label1: TLabel
          Width = 52
          Hint = 'Voice-Charging-Forwarding-Call'
          Caption = 'Forwarded'
          ExplicitWidth = 52
        end
        inherited Label2: TLabel
          Width = 56
          Hint = 'Voice-Charging-Terminating-Call'
          Caption = 'Terminating'
          ExplicitWidth = 56
        end
        inherited CheckBox2: TCheckBox
          Hint = 'Voice-Charging-Terminating-Call'
        end
        inherited CheckBox1: TCheckBox
          Hint = 'Voice-Charging-Forwarding-Call'
        end
        inherited CheckBox0: TCheckBox
          Hint = 'Voice-Charging-Originating-Call'
        end
        inherited Series3: TBarSeries
          BarStyle = bsRectangle
        end
      end
    end

The unit header:

unit CCN;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, ComCtrls, StdCtrls, NodeClasses, NSPmagazine, NSP,
  OleCtrls, TSP, Linux, Services, SmartChart, DB,
  ZAbstractRODataset, ZAbstractDataset, ZAbstractTable, ZDataset,
  ZConnection, ZAbstractConnection;

type TCCN = class(TNode)
    procedure GetConfig;   override;
    procedure GetStatus;   override;
    procedure GetCounters; override;

private
    procedure PlotCountersDBRowToCharts(ZQuery: TZQuery);
end;

type
  TFrameCCN = class(TFrame)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    TabSheet4: TTabSheet;
    Panel1: TPanel;
    FrameNSP: TFrameNSP;
    FrameTSP: TFrameTSP;
    Label1: TLabel;
    Edit1: TEdit;
    FrameLinux: TFrameLinux;
    Label2: TLabel;
    RichEdit1: TRichEdit;
    TabSheet5: TTabSheet;
    Frame51: TFrame5;
    PageControl2: TPageControl;
    TabSheet6: TTabSheet;
    TabSheet7: TTabSheet;
    TabSheet8: TTabSheet;
    TabSheet9: TTabSheet;
    ZConnection1: TZConnection;  
    ZQueryCounters: TZQuery;     
    ZQueryCountersHistory: TZQuery;
    ScrollBox1: TScrollBox;
    DateTimePickerFirst: TDateTimePicker;
    DateTimePickerLast: TDateTimePicker;
    FrameSmartChart1: TFrameSmartChart;
    FrameSmartChart2: TFrameSmartChart;
    FrameSmartChart3: TFrameSmartChart;
    FrameSmartChart4: TFrameSmartChart;
    FrameSmartChart5: TFrameSmartChart;
    FrameSmartChart6: TFrameSmartChart;
    FrameSmartChart7: TFrameSmartChart;
    FrameSmartChart8: TFrameSmartChart;
    FrameSmartChart9: TFrameSmartChart;
    FrameSmartChart10: TFrameSmartChart;
    FrameSmartChart11: TFrameSmartChart;
    Shape1: TShape;
    Shape3: TShape;
    Shape4: TShape;
    Shape5: TShape;
    Shape6: TShape;
    Shape7: TShape;
    FrameSmartChart12: TFrameSmartChart;
    FrameSmartChart13: TFrameSmartChart;
    Shape8: TShape;
    Shape9: TShape;
    Shape10: TShape;
    Shape11: TShape;
    Shape12: TShape;
    Shape13: TShape;
    Shape14: TShape;
    Shape15: TShape;
    Shape16: TShape;
    Shape17: TShape;
    Shape18: TShape;
    Shape19: TShape;
    Shape20: TShape;
    Shape21: TShape;
    Shape22: TShape;
    Shape23: TShape;
    Shape24: TShape;
    Shape25: TShape;
    Shape26: TShape;
    Shape27: TShape;
    Shape28: TShape;
    FrameSmartChart14: TFrameSmartChart;
    Shape29: TShape;
    ScrollBox2: TScrollBox;
    FrameSmartChart15: TFrameSmartChart;
    FrameSmartChart16: TFrameSmartChart;
    FrameSmartChart17: TFrameSmartChart;
    FrameSmartChart18: TFrameSmartChart;
    FrameSmartChart19: TFrameSmartChart;
    FrameSmartChart20: TFrameSmartChart;
    Shape2: TShape;
    FrameSmartChart21: TFrameSmartChart;
    FrameSmartChart22: TFrameSmartChart;
    FrameSmartChart23: TFrameSmartChart;
    FrameSmartChart24: TFrameSmartChart;
    Shape30: TShape;
    Shape31: TShape;
    Shape32: TShape;
    Shape33: TShape;
    Shape34: TShape;
    Shape35: TShape;
    Shape36: TShape;
    Shape37: TShape;
    Shape38: TShape;
    Shape39: TShape;
    Shape40: TShape;
    Shape41: TShape;
    TabSheet10: TTabSheet;
    ScrollBox3: TScrollBox;
    FrameSmartChart25: TFrameSmartChart;
    FrameSmartChart26: TFrameSmartChart;
    Shape42: TShape;
    Shape43: TShape;
    FrameSmartChart27: TFrameSmartChart;
    Shape44: TShape;
    FrameSmartChart28: TFrameSmartChart;
    Shape45: TShape;
  private
    { Private declarations }
  public
  end;

implementation

{$R *.dfm}

uses SSH, NOCMagic, NSPprocessor, Log, DateUtils, SqlTimSt, DbChart, StrUtils,
  InfoMessage, Series;

IDE into IDE debugger breaks with the Out Of Memory Error at the below line:

KERNELBASE.GetLastError:
75B445B0 64A118000000     mov eax, fs:[$00000018]
75B445B6 8B4034           mov eax,[eax+$34]
75B445B9 C3               ret 
75B445BA CC               int 3
75B445BB CC               int 3
75B445BC CC               int 3
75B445BD CC               int 3
75B445BE CC               int 3
75B445BF CC               int 3
KERNELBASE.RaiseException:
75B445C0 8BFF             mov edi,edi
75B445C2 55               push ebp
75B445C3 8BEC             mov ebp,esp
75B445C5 83E4F8           and esp,-$08
75B445C8 83EC58           sub esp,$58
75B445CB A1345DBE75       mov eax,[$75be5d34]
75B445D0 33C4             xor eax,esp
75B445D2 89442454         mov [esp+$54],eax
75B445D6 8B4508           mov eax,[ebp+$08]
75B445D9 8B4D14           mov ecx,[ebp+$14]
75B445DC 8364240800       and dword ptr [esp+$08],$00
75B445E1 890424           mov [esp],eax
75B445E4 8B450C           mov eax,[ebp+$0c]
75B445E7 83E001           and eax,$01
75B445EA C744240CC045B475 mov [esp+$0c],$75b445c0
75B445F2 89442404         mov [esp+$04],eax
75B445F6 85C9             test ecx,ecx
75B445F8 7439             jz $75b44633
75B445FA 8B4510           mov eax,[ebp+$10]
75B445FD 83F80F           cmp eax,$0f
75B44600 7738             jnbe $75b4463a
75B44602 89442410         mov [esp+$10],eax
75B44606 C1E002           shl eax,$02
75B44609 50               push eax
75B4460A 51               push ecx
75B4460B 8D44241C         lea eax,[esp+$1c]
75B4460F 50               push eax
75B44610 E8AFC40100       call $75b60ac4
75B44615 83C40C           add esp,$0c
75B44618 8D0424           lea eax,[esp]
75B4461B 50               push eax
75B4461C FF159093BE75     call dword ptr [$75be9390]

-> 75B44622 8B4C2454         mov ecx,[esp+$54]

75B44626 33CC             xor ecx,esp
75B44628 E8A3EF0000       call $75b535d0
75B4462D 8BE5             mov esp,ebp
75B4462F 5D               pop ebp
75B44630 C21000           ret $0010
75B44633 8364241000       and dword ptr [esp+$10],$00
75B44638 EBDE             jmp $75b44618
75B4463A 6A0F             push $0f

My guess right now is that the problem started when I passed about 25 frames/charts, if there's some kind of limitation there. My problem is that I can't break down this form into smaller ones, as the charts I'm presenting only make sense when shown together (they are parts of a larger production flow). And I barely started, I was planning on having 35-40 graphs.

Considering my project works OK at run-time, one solution would be to add the frames/charts at run-time, but that kinda defeats the purpose of using a RAD.

Any help appreciated, thanks.

Flav
  • 41
  • 2
  • You can't *attach* anything here. Open the .DFM as text with your favorite editor (including Notepad), Ctrl+A to select all, switch to your post here, [edit] it, and paste with Ctrl+V. Select the contents of the .DFM again, and hit Ctrl+I or the **{}** toolbar button to format it as code. – Ken White Mar 29 '19 at 18:37
  • 1
    Also, FWIW: The Delphi IDE is 32-bit, so all of the extra RAM you have available isn't going to be of great use. – Ken White Mar 29 '19 at 18:44
  • I suspect you're running into a limitation of the size of a single resource. The contents of the .DFM are compiled to binary and linked directly into the executable, and then streamed in by your app at runtime. The resource size is embedded as part of that resource as a DWORD value. A single DFM of 100k lines could pretty easily exceed that DWORD. – Ken White Mar 29 '19 at 21:01
  • OK, I made a mistake, it was 114000 chars, not lines (corrected the post too). So total lines is little above 3000, file size is 101 KB. Piece of nothing. Besides that, as I said before the project compiles and runs fine, form shows up at run-time, so it's clearly not a matter of resource size. However it is clearly related to the number of frames/components. I went back to an older version with less charts and it opened no problem. So the only way out I'm seeing right now is to delete a few frames from the DFM until it opens properly and create them in the code at run-time. – Flav Mar 29 '19 at 21:55
  • Close the IDE, reboot your PC, delete the project's .Dsk file and then re-open the IDE and your project. After that, do you still get the error? – MartynA Mar 29 '19 at 22:50
  • Yes, still getting the error unfortunately. – Flav Mar 30 '19 at 07:57
  • Another thing to try: Run the IDE and load a second instance of the IDE into it. Then, in the second instance load your project and open the problem form. The first instance of the IDE should catch the error, and viewing the call stack may show you exactly where the error is occurring. Loading one instance of the IDE into another is a way of debugging BPLs, btw. – MartynA Mar 30 '19 at 13:27
  • Took me a while to figure out how to do that. Run/Load Process, for future reference. After a few "stuff already in use" errors, the 2nd IDE started eventually and caught the error indeed. But I doubt I could ever make any sense out of the assembly code. I pasted it in the post. Thanks for the tip. – Flav Apr 01 '19 at 09:35
  • How about creating a single TForm and put it into the Project Options > Applications > Forms into available. Then add all components you plan to use on the form, then adjust the form how you like it for each one you have. Record locations of the components and which you want to be visible. Then create the forms at runtime for any amount needed. You'll then be able to show all of them at runtime at the same time. – El Diablo Dec 21 '19 at 17:57

0 Answers0