Board index » delphi » TP6: mem-shortage [compile error 49]

TP6: mem-shortage [compile error 49]

Hi,

Can someone help me, I think I got a serious problem.
Here it is:
During the compiling of a program I'm working on, I
get the message:

     Error 49: Data segment too large.

The message is clear, but so isn't the solution.
BTW I'm using TP6 (no Windows or whatsoever).

If someone knows a solution, I'm eager to hear/read it.

Thanks in advance for any help,

Arjaan den Ouden
Rotterdam
The Netherlands

 

Re:TP6: mem-shortage [compile error 49]


In article <DHDu31....@cs.few.eur.nl> bicdo...@cs.few.eur.nl (Arjaan C. den Ouden) writes:

Quote
>From: bicdo...@cs.few.eur.nl (Arjaan C. den Ouden)
>Subject: TP6: mem-shortage [compile error 49]
>Date: Wed, 1 Nov 1995 20:54:37 GMT
>Hi,
>Can someone help me, I think I got a serious problem.
>Here it is:
>During the compiling of a program I'm working on, I
>get the message:
>     Error 49: Data segment too large.
>The message is clear, but so isn't the solution.
>BTW I'm using TP6 (no Windows or whatsoever).
>If someone knows a solution, I'm eager to hear/read it.
>Thanks in advance for any help,

Arjaan,

The reason of the problem is that you have declared all static variables
e.g.
var aReal : real;

In a pascal program (or may be even all MS-Dos programs) the size of the data
segment is limited to 64 kB (i.e. the size of one memory paragraph).

Try using pointers (alias dynamic variables} instead. These will be allocated
on the heap which is as large as you want (within the limits of your
computers RAM).

example:
type
  Preal = ^real;    {define a pointer to a real}

var
  aReal : PReal;  {this will be your dynamic variable}

...
New(aReal);       {allocate space on the heap}
aReal^ := 9.23;    {you can now assign a value to your variable}
...
Dispose(aReal); {when you don't need it anymore, free the memory}

I suggest you do some reading about pointers. Good luck,

Harold Veelenturf
CombiR...@box.nl
the Netherlands

Re:TP6: mem-shortage [compile error 49]


On Wed, 1 Nov 1995, Arjaan C. den Ouden wrote:

Quote

> Hi,

> Can someone help me, I think I got a serious problem.
> Here it is:
> During the compiling of a program I'm working on, I
> get the message:

>      Error 49: Data segment too large.

> The message is clear, but so isn't the solution.
> BTW I'm using TP6 (no Windows or whatsoever).

> If someone knows a solution, I'm eager to hear/read it.

What you'll want to do is change all of your large structures to
*pointers* to the large structure.  For example, if you've got something
like:

var
  Dots: array[0..99] of record
    x, y, z : word;
   end;

begin
  for i := 0 to 99 do
    Dots[i].x := 42;
end.

change it to this:

type
  TDots: Array[0..99] of record
    x, y, z : word;
   end;
  PDots : ^TDots;

var
  Dots : PDots;

begin
  new (Dots);  { DON'T forget to new() your pointers!!! :) }
  for i := 0 to 99 do
    Dots^[i].x := 42;
end.

If you don't need all your data at any given time, you can dispose() your
various structures when they're not needed any more.  Just remember: any
reference to the structure as a variable now has a ^ between the variable
name and the structure.

I suggest you read up on pointers, data structures, etc. in the various
manuals.  The manuals are actually pretty useful, at least if you're a
beginner.

    ________________________________________________________________________
   / Joshua Shagam                    /    (Quantum Porcupine / Versatile) /
  / mailto:JSha...@nmsu.edu          /       http://web.nmsu.edu/~jshagam /
 / phone://1.505.645.3856/~joshua   /  for the Quantum Porcupine Archive /
/__________________________________/____________________________________/
\ The opinions expressed are not   \        Of course, porcupines don't \
 \ necessarily those of anyone else \    *NEED* any damn disclaimers! :) \
  \__________________________________\____________________________________\
Q: How many hoards would the monguls board if the mongul hordes got bored?
A: The monguls would board all the hoards if the hordes got really bored

Re:TP6: mem-shortage [compile error 49]


Re:TP6: mem-shortage [compile error 49]


: You have more than 64K data, that's not a memory shortage. One solution would
: be to assign large data structures dynamically, that is using GetMem (and
: FreeMem)

Another solution is sending an e-mail to Borland
telling then that they should at last develop
a new Borland Pascal for DOS without such
silly restrictions.

Klaus
--
Klaus Hartnegg, Institut fuer Biophysik, Hansa-Strasse 9a, D-79104 Freiburg
Tel +49 761 203 9516, Fax 9540, e-mail: hartn...@uni-freiburg.de

Other Threads