Forum > General

Heap overflow error in GetControlText after TMemo.Lines.LoadFromFile

(1/5) > >>

NOPIK:
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);
begin
  if (OpenDialog1.Execute) then
  begin
    Memo1.Visible := false;
    Memo1.Lines.BeginUpdate;
    Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
    Memo1.Lines.EndUpdate;
    Memo1.Visible := true;
  end;
end;

--- 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)

cdbc:
Hi

--- 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

Thaddy:
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

Zvoni:

--- 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: https://lazarus-ccr.sourceforge.io/docs/lcl/stdctrls/tcustommemo.lines.html
TStrings has "Count", which is "integer": https://lazarus-ccr.sourceforge.io/docs/rtl/classes/tstrings.count.html
And Range of "Integer" depends on Mode: https://lazarus-ccr.sourceforge.io/docs/rtl/system/integer.html

--- 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?

Thaddy:
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.

Navigation

[0] Message Index

[#] Next page

Go to full version