Forum > General

Heap overflow error in GetControlText after TMemo.Lines.LoadFromFile

(1/5) > >>

Very long loading time aside - I got an Heap overflow error on application Close(!) in GetControlText(???) in very simple program:

--- Code: ---procedure TForm1.Button1Click(Sender: TObject);
  if (OpenDialog1.Execute) then
    Memo1.Visible := false;
    Memo1.Visible := true;

--- End code ---
I'm loading test XML file only 97Mb in length, 450K lines (Small for my data and must be no sweat for Win32 Lazarus)


--- Quote ---Small for my data
--- End quote ---
It may be small for you, but it ain't for the memo-control. search the net, 'cause I know there are some limit to how much you can stuff into a memo-control on win32.
Regards Benny

On windows, compiled for 32 bit,  the Tmemo uses the windows class EDIT and that has by default severe limitations for the size it can handle.
It is limited to 2 GB data and/or 32767 lines and/or available memory, whatever comes first.
There are work-arounds: I think richmemo has the capacity to load larger files.
The windows API class RICHEDIT2 or higher can be created with BOTTOMLESS in CreateParams, which gives you essentially windowed access to very large files using the windows file mapping API. I don't know if this is implemented for e.g. TRichView on Lazarus.
In KOL we have the bottomless property for RichEdit surfaced.
So my advice is to check TRichview first


--- Quote from: NOPIK on June 12, 2024, 12:28:26 pm ---I'm loading test XML file only 97Mb in length, 450K lines (Small for my data and must be no sweat for Win32 Lazarus)

--- End quote ---
Lines of TMemo is a TStrings:
TStrings has "Count", which is "integer":
And Range of "Integer" depends on Mode:

--- Quote ---The system unit defines Integer as a signed 16-bit integer. But when DELPHI or OBJFPC mode are active, then the objpas unit redefines Integer as a 32-bit integer.
--- End quote ---

16-Bit signed: --> 32767 max

What mode is in that module?

Zvoni, that is not relevant here, the specs are from msdn.
The RICHEDIT2 (or msft)  control has different specs and can handle huge files,
but I don't know if they are surfaced in Lazarus.


[0] Message Index

[#] Next page

Go to full version