Board index » delphi » DOS and Borland Pascal memory size

DOS and Borland Pascal memory size

{whispering so as not to attract the attention of the 'wrong newsgroup
posting monitors')

free pascal (fpc ) allowz much larger arrays than does bpc/tpc 7.0 and
it will run on the system you have - I have some very large code running
on 486's.

Delphi 2.0 (dcc32) (Borland Pascal 9.0) can handle [1..10000],[1..10000]
fpc gives a 'Load error: no DPMI memory' error at [1..4000],[1..4000]

with fpc [1..3000],[1..3000] it appears to be using the disk drive for
virtual memory usage??

fpc runs [1..2000],[1..2000] (optimized) in 4.62 seconds on a P166 Cyrix
dcc32 runs [1..2000],[1..2000] in 14.92 seconds on a P166 Cyrix

program arraymem;

var i  : integer;
    j  : integer;
    n  : integer;

 mt : array[1..2000, 1..2000] of string;

{ mt : array[1..3000, 1..3000] of string; }  { runs on disk/virtual ?? }

{ mt : array[1..4000, 1..4000] of string; } { fpc : Load error: no DPMI
memory }

{ mt  : array[1..10000, 1..10000] of string; } { delphi }

begin

writeln;
write('writing to array');

n := 2000;
for i := 1 to n do
  for j := 1 to n do mt[i,j] := '0';
writeln;

writeln('mt[',(n-1),',',(n-1),'] : ', mt[(n-1),(n-1)]);

end.

Quote
Ian Upton wrote:

> I have a simple application which will be run on old hardware in the middle
> of athletic tracks and therefore I am using DOS and Borland Pascal V7.0.

> I am having troubles with memory and need assistance in understanding how
> much memory I can utilise in the program.

> The hardware is a 486 @ 100MH with 16MB of memory.

> With BP targeted towards PROTECTED mode the largest HEAP size I can
> get (MemAvail command) is around 1MB. I require more than this for a couple
> of large arrays.

> DOS HIMEM.SYS loaded.
> All the Borland DPMI and RTM is in the correct Place.
> A DOS MEM /C command shows 13MB of free extended memory.

> Can anyone help with information on how memory is allocated between DOS, the
> Borland runtime environment, etc.

> Thanks Ian Upton

 

Re:DOS and Borland Pascal memory size


Quote
On Wed, 8 Sep 1999, enztec wrote:
> free pascal (fpc ) allowz much larger arrays than does bpc/tpc 7.0 and
> it will run on the system you have - I have some very large code running
> on 486's.

> Delphi 2.0 (dcc32) (Borland Pascal 9.0) can handle [1..10000],[1..10000]
> fpc gives a 'Load error: no DPMI memory' error at [1..4000],[1..4000]

That is because a Windows Dos box only allows you to use 64MB of DPMI
memory (if you set it at that value, I believe the default is even only
16MB). Use the Win32 version of the compiler to compile Win32 programs and
you won't have those problems (or run your programs under real Dos, not in
a dos box).

Quote
> with fpc [1..3000],[1..3000] it appears to be using the disk drive for
> virtual memory usage??

FPC simply requests memory from the operating system, it's up to that one
whether it uses virtual memory or not.

Quote
> fpc runs [1..2000],[1..2000] (optimized) in 4.62 seconds on a P166 Cyrix
> dcc32 runs [1..2000],[1..2000] in 14.92 seconds on a P166 Cyrix

That's nice :)

Jonas

Re:DOS and Borland Pascal memory size


Quote
Jonas Maebe wrote:
> That is because a Windows Dos box only allows you to use 64MB of DPMI
> memory (if you set it at that value, I believe the default is even
> only 16MB).

Could you please tell me where I can set the DPMI value to 64 MB. The
fpc documents - say that it is 4MB but expands to use the total
available on it's own. Is this not happening?

Quote
> Use the Win32 version of the compiler to compile Win32
> programs and you won't have those problems (or run your programs under
> real Dos, not in a dos box).

Running in real dos is not a real option as I would lose all access to
my network.
But when I ran it in real dos (no windows loaded at all) it went to disk
(under OS control?) even for the low array size [1..2000],[1..2000] and
performance was horrible - 50% increase in time.

Could you please tell me if I can run the fpc Win32 version from a Dos
box, as I only program at the command line but use windows 95 for access
to network drives and 32 bit features.

I am sorry to not install win32 version before asking this and seeing
for myself, but I refrain from loading windows 95 software unless I have
to, for fear that the win95 registry will not be returned to the way it
was before loading the win95 based software - if I decide to uninstall
it.

May I assume this memory problem situation disappears under Linux - a
true 32 bit OS NOT running on top of an 8 bit OS (dos).

Quote
> > with fpc [1..3000],[1..3000] it appears to be using the disk drive
> > for virtual memory usage??

> FPC simply requests memory from the operating system, it's up to that > one whether it uses virtual memory or not.

In real dos mode I assume you mean command.com - Have you had any
experience with the fpc compiler running under the 4dos.com command.com
replacement OS??

Quote
> > fpc runs [1..2000],[1..2000] (optimized) in 4.62 seconds on a P166
> > Cyrix
> > dcc32 runs [1..2000],[1..2000] in 14.92 seconds on a P166 Cyrix

> That's nice :)

I am really glad it isn't the other way around!!! My tests on real
floating point division also show a 2.5 times benefit to fpc over bpc
and even dcc32.

Re:DOS and Borland Pascal memory size


Quote
Jonas Maebe wrote:

> > fpc runs [1..2000],[1..2000] (optimized) in 4.62 seconds on a P166 Cyrix
> > dcc32 runs [1..2000],[1..2000] in 14.92 seconds on a P166 Cyrix

> That's nice :)

No, it's plain misrepresentation. Delphi strings are completely
different beast and are "long": using reference counting and dynamic
memory allocation.

For a *sensible* speed comparison, try using the Delphi shortstring
type.

MH.

--
Martin Harvey.
mc...@harvey27.demon.co.uk
http://www.harvey27.demon.co.uk/mch24/

Re:DOS and Borland Pascal memory size


Where is the misrepresentation?? lol
I use the same program just the different compilers.

It sounds like you are really saying that fpc has a better algorithm for
AnsiStrings than bpc/tpc 7.0 does. Isn't that what the comparison shows?

Don't both compilers use dynamic allocation?

Your argument is like saying - if I test umbrellas and yours doesn't
hold up in the rain - you tell me that it a bad test and I should test
them in the sun - well I want to test them in the RAIN under the
conditions I want to use the umbrellas/program!

I don't want to use shortstrings, I want to use AnsiStrings and test the
difference in how fast the compiled code for each compiler handles
AnsiStrings.

By the way - how does fpc handle AnsiStrings? If you don't know it then
you shopuldn't say anything.

Quote
Martin Harvey wrote:

> Jonas Maebe wrote:

> > > fpc runs [1..2000],[1..2000] (optimized) in 4.62 seconds on a P166 Cyrix
> > > dcc32 runs [1..2000],[1..2000] in 14.92 seconds on a P166 Cyrix

> > That's nice :)

> No, it's plain misrepresentation. Delphi strings are completely
> different beast and are "long": using reference counting and dynamic
> memory allocation.

> For a *sensible* speed comparison, try using the Delphi shortstring
> type.

Re:DOS and Borland Pascal memory size


Quote
On Wed, 8 Sep 1999, enztec wrote:
> > That is because a Windows Dos box only allows you to use 64MB of DPMI
> > memory (if you set it at that value, I believe the default is even
> > only 16MB).
> Could you please tell me where I can set the DPMI value to 64 MB. The
> fpc documents - say that it is 4MB but expands to use the total
> available on it's own. Is this not happening?

No, because Windows doesn't give anymore memory to FPC (or any other
DPMI program) once it has reached the limit set for the dosbox. I just
checked and it seems you even can't give more than 16MB of DPMI memory to
a Dos box (under NT4 anyway), so that's bad luck.

To check it for yourself, create a new shortcut, click on it with the
right mouse button, choose properties, go to the memory tab and check the
last pop-up mebnu in the first column (that's for DPMI memory). I can't
set it higher than 16384 KB here.

Quote
> But when I ran it in real dos (no windows loaded at all) it went to disk
> (under OS control?) even for the low array size [1..2000],[1..2000] and
> performance was horrible - 50% increase in time.

That's strange, it should not do that. Anyway, as I said before: FPC
itself does/can not control whether real or virtual memory is used: it
simply requests a block of memory and the DPMI host/operating system gets
that memory from wherever it want to.

Quote
> Could you please tell me if I can run the fpc Win32 version from a Dos
> box, as I only program at the command line but use windows 95 for access
> to network drives and 32 bit features.

Of course. You can start any windows program from a dosbox under WinXX.

Quote
> I am sorry to not install win32 version before asking this and seeing
> for myself, but I refrain from loading windows 95 software unless I have
> to, for fear that the win95 registry will not be returned to the way it
> was before loading the win95 based software - if I decide to uninstall
> it.

FPC does not add/change a single thing in the registry. It even doesn't
modify your autoexec.bat, the install pogram simply suggests you to add
the directory to the binaries to your path.

Quote
> May I assume this memory problem situation disappears under Linux - a
> true 32 bit OS NOT running on top of an 8 bit OS (dos).

Yes. Although you don't have any memory limits (except maybe for 2GB or
4GB) under Win32 either.

Quote
> > FPC simply requests memory from the operating system, it's up to that
> > one whether it uses virtual memory or not.
> In real dos mode I assume you mean command.com - Have you had any
> experience with the fpc compiler running under the 4dos.com command.com
> replacement OS??

No, command.com or 4dos.com are not operating systems, they are simply
command line shells. This has nothing to do with memory management. Yes,
FPC runs fine with 4dos.

Quote
> I am really glad it isn't the other way around!!! My tests on real
> floating point division also show a 2.5 times benefit to fpc over bpc
> and even dcc32.

That's really strange, in our benchmarks it's often the other way round.
Anyway, I'm glad you like it.

Jonas

Re:DOS and Borland Pascal memory size


Quote
On Thu, 9 Sep 1999, enztec wrote:
> Where is the misrepresentation?? lol
> I use the same program just the different compilers.

But they have different defaults.

Quote
> It sounds like you are really saying that fpc has a better algorithm for
> AnsiStrings than bpc/tpc 7.0 does. Isn't that what the comparison shows?

TP/BP don't have ansistrings.

Quote
> Don't both compilers use dynamic allocation?

For ansistrings, yes. For shortstrings, no.

Quote
> I don't want to use shortstrings, I want to use AnsiStrings and test the
> difference in how fast the compiled code for each compiler handles
> AnsiStrings.

Then add this to the top of your program:

{$ifdef fpc}
{$mode delphi}
{$endif fpc}
{$h+}

This forces FPC into Delphi compatibility mode and ansistrings on (so if
you declare a variable as string, it is interpreted as an ansistring).

Jonas

Re:DOS and Borland Pascal memory size


Quote
On Wed, 8 Sep 1999, Martin Harvey wrote:
> > > fpc runs [1..2000],[1..2000] (optimized) in 4.62 seconds on a P166 Cyrix
> > > dcc32 runs [1..2000],[1..2000] in 14.92 seconds on a P166 Cyrix

> > That's nice :)

> No, it's plain misrepresentation. Delphi strings are completely
> different beast and are "long": using reference counting and dynamic
> memory allocation.

I thought that inb {$h+} mode (default) string = ansistring and in {$h-}
string = shortstring under Delphi? To get the strings you talk about, you
have to specify LongString as type identifier afaik (and I do mean afaik,
I have very little knowledge about Delphi).

Note that LongStrings are not yet fully implemented in FPC.

Quote
> For a *sensible* speed comparison, try using the Delphi shortstring
> type.

Or put {$h+} at the top of the source.

Jonas

Re:DOS and Borland Pascal memory size


Quote
Jonas Maebe wrote:

> On Thu, 9 Sep 1999, enztec wrote:

> > Where is the misrepresentation?? lol
> > I use the same program just the different compilers.

> But they have different defaults.

> > It sounds like you are really saying that fpc has a better algorithm for
> > AnsiStrings than bpc/tpc 7.0 does. Isn't that what the comparison shows?

> TP/BP don't have ansistrings.

I am sorry - we were discussing Delphi and fpc - I said tp/bp when I
meant delphi - I have stopped using bp/tp - only delphi and fpc now

Quote
> > I don't want to use shortstrings, I want to use AnsiStrings and test the
> > difference in how fast the compiled code for each compiler handles
> > AnsiStrings.

> Then add this to the top of your program:

> {$ifdef fpc}
> {$mode delphi}
> {$endif fpc}
> {$h+}

> This forces FPC into Delphi compatibility mode and ansistrings on (so > if you declare a variable as string, it is interpreted as an ansistring).

I have -Sh set in the ppc386.cfg file - same thing??

Re:DOS and Borland Pascal memory size


Quote
Jonas Maebe wrote:
> I thought that in {$h+} mode (default) string = ansistring and in
> {$h-} string = shortstring under Delphi?

True.

Quote
> To get the strings you talk about, you have to specify LongString as
> type identifier afaik (and I do mean afaik, I have very little
> knowledge about Delphi).

I run delphi with default (H+) and I get the string treatment I want -
string is considered an AnsiString. I don't declare string longstring.

Quote
> Note that LongStrings are not yet fully implemented in FPC.

I just started converting my delpi programs over to fpc and they have a
range check problem with -H+ in ppc386.cfg.

in fpc :
var s : string;

and it gives

and unhandled exception occurred at 0000BA8E
Range check error

the string it bombs on is 152221 characters long length(s)  - It works
on a string 9382 characters - I don't know its' limit but it is
somewhere in between. (64K??)

Re:DOS and Borland Pascal memory size


Quote
On Thu, 9 Sep 1999, enztec wrote:
> > {$ifdef fpc}
> > {$mode delphi}
> > {$endif fpc}
> > {$h+}

> > This forces FPC into Delphi compatibility mode and ansistrings on (so > if you declare a variable as string, it is interpreted as an ansistring).
> I have -Sh set in the ppc386.cfg file - same thing??

-Sh is the same as {$h+}

If you want the effect of {$mode delphi}, you also need -Sd. This causes
FPC to always add the objpas unit to your program, so the Delphi style
memory manager gets installed and the integer type is redefined to 32bit.
It also enables syntax compatibility with Delphi (for example, nesting of
comments is switched off).

Note that if you add that switch to your ppc386.cfg, ALL programs will be
compiled with these settings unless you specify another syntax switch on
the copmmand line. This may cause problems for programs which are written
with the expectation that integer = 16bits.

If you want Delphi syntax with FPC features (operator overloading etc),
use -S2 or {$mode objfpc}.

Jonas

Re:DOS and Borland Pascal memory size


Quote
On Thu, 9 Sep 1999, enztec wrote:
> in fpc :
> var s : string;

> and it gives

> and unhandled exception occurred at 0000BA8E
> Range check error

> the string it bombs on is 152221 characters long length(s)  - It works
> on a string 9382 characters - I don't know its' limit but it is
> somewhere in between. (64K??)

There is no built-in limit regarding the size of a string. Can you send me
(via email, not in the news group) the program and a (not too big)
datafile? And does the offending program work correctly with Delphi?

Jonas

Other Threads