Recent

Author Topic: Error: Identifier not found "MaxHeapSize" when compiling for DOS  (Read 380 times)

Yoghoo

  • Newbie
  • Posts: 4
I'm writing a Turbo Vison application for DOS but unfortunately when compiling it gives an error with Free Pascal. Example code:

Quote
constructor test_app.Init;
begin
  MaxHeapSize := 8192;
  inherited Init;
end;

The error it gives (with MSDOS or GO32v2 as targets):
Quote
Error: Identifier not found "MaxHeapSize".

The code compiles perfectly fine in Turbo Pascal 7.0. Also MaxHeapSize is used in the Turbo Vision Programming Guide from Borland.

Is MaxHeapSize defined in a non default library or did Free Pascal not implement it?

Thaddy

  • Hero Member
  • *****
  • Posts: 17414
  • Ceterum censeo Trumpum esse delendum (Tnx Charlie)
Re: Error: Identifier not found "MaxHeapSize" when compiling for DOS
« Reply #1 on: June 21, 2025, 03:11:04 pm »
{$MEMORY stacksize, heapsize}
https://www.freepascal.org/docs-html/prog/progsu102.html

There is also {$MAXSTACKSIZE $FFFF}, but no {$MAXHEAPSIZE $FFFF}

You can set stack and heap size also from the commandline. In that case you can set them separately:
-Ch and -Cs
I your case -Ch8192
In general, TP or FPC in $mode TP, you should leave the heap alone and just adjust the stack.
The worse you can get from adjusting the heap is EOutOfMemory or an RTE 203.
Just in case of TSR's you might limit the heap.
« Last Edit: June 21, 2025, 03:23:40 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Yoghoo

  • Newbie
  • Posts: 4
Re: Error: Identifier not found "MaxHeapSize" when compiling for DOS
« Reply #2 on: June 21, 2025, 03:44:28 pm »
{$MEMORY stacksize, heapsize}
https://www.freepascal.org/docs-html/prog/progsu102.html

There is also {$MAXSTACKSIZE $FFFF}, but no {$MAXHEAPSIZE $FFFF}

You can set stack and heap size also from the commandline. In that case you can set them separately:
-Ch and -Cs
I your case -Ch8192
In general, TP or FPC in $mode TP, you should leave the heap alone and just adjust the stack.
The worse you can get from adjusting the heap is EOutOfMemory or an RTE 203.
Just in case of TSR's you might limit the heap.

So Free Pascal does indeed not have MAXHEAPSIZE. When I read the Borland documentation I see this about this parameter:

Quote
The Editors unit declares a global variable called MaxHeapSize that
you must set if your application uses file editors. MaxHeapSize
defaults to 640K, meaning that your application's heap get all
available memory, with no memory available for file edit buffers.
If you try to use a file editor without setting aside buffer space,
your program will crash and possibly hang your system.
There are two things you need to be aware of about Ma~HeapSize:
• It specifies the size of your application's heap in 16-byte paragraphs.
Memory beyond that amount is not available to the rest .
of your application, so be sure to allocate enough. Setting
MaxHeapSize to 4096, for example, sets aside 64K for the appli.:.
cation's heap, with everything else left for file edit buffers .
• You must set MaxHeapSize before allocating any memory from
the heap. The safest thing to do is make it the first statement in
your application object's constructor, before calling the inherited
constructor.

Reading this are you sure that this parameter is the same as {$M}? If I look at all programs written in Turbo Pascal with Turbo Vision they use {$M} and MAXHEAPSIZE together. Not only {$M}.

In Turbo Pascal {$M} has 3 parameters: stacksize, heapmin and heapmax btw. So Free Pascal has only 2? It does not complain when using 3 parameters but I don't know if the 3th one is used then.

Thaddy

  • Hero Member
  • *****
  • Posts: 17414
  • Ceterum censeo Trumpum esse delendum (Tnx Charlie)
Re: Error: Identifier not found "MaxHeapSize" when compiling for DOS
« Reply #3 on: June 21, 2025, 04:30:14 pm »
MaxHeapSize should live in system but is not documented there and it errors, so it is not there..
For your other question: there are more defines dealing with that.
Like {$MINSTACKSIZE xxxx}.
https://www.freepascal.org/docs-html/current/prog/progsu103.html#x111-1120001.3.20

Third third parameter of {$MEMORY }IS used, so that is fine, but a bit of a bug in the documentation.
« Last Edit: June 21, 2025, 04:38:12 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

Yoghoo

  • Newbie
  • Posts: 4
Re: Error: Identifier not found "MaxHeapSize" when compiling for DOS
« Reply #4 on: June 22, 2025, 05:49:44 pm »
MaxHeapSize should live in system but is not documented there and it errors, so it is not there..
For your other question: there are more defines dealing with that.
Like {$MINSTACKSIZE xxxx}.
https://www.freepascal.org/docs-html/current/prog/progsu103.html#x111-1120001.3.20

Third third parameter of {$MEMORY }IS used, so that is fine, but a bit of a bug in the documentation.

Thanks for the info. Trying to play with those settings but it seems futile. It looks as if those parameters are not used at all.

I can't get a Turbo Vision application running with MSDOS as a target. As soon as I do a InsertWindow it will hang (with -WmLarge) or reboot (with -WmHuge) the pc.

If I run it in Turbo Pascal it runs fine. Also if the target is Go32v2 it runs fine. But as I want it to run on 286 CPU's as well that's not an option.

This is just with the demo application from the Turbo Vision Programming Guide so nothing fancy. Only added FVConsts as that is needed in Free Pascal.

If anybody has a working example to open a text file with InsertWindow (with MSDOS as target) in Free Pascal please let me know.

Yoghoo

  • Newbie
  • Posts: 4
Re: Error: Identifier not found "MaxHeapSize" when compiling for DOS
« Reply #5 on: June 22, 2025, 06:34:44 pm »
Just found out that Free Pascal also has an example (in my case installed in: E:\FPC\3.2.2\examples\fv\testapp.pas).

That one also has the exact same problem as described above with the Borland demo. So either MSDOS target is bugged or is not supported.:(

 

TinyPortal © 2005-2018