Board index » delphi » Data segment too large

Data segment too large

Hallo

I hope you can help me.

What is the simplest way to avoid the
error 49 "Data segment too large".

Please help me.

Skriv Svenska om du kan.

 

Re:Data segment too large


Quote
In article <32D53837.3...@hotmail.com>, Daniel  <daniel...@hotmail.com> wrote:
>Hallo

>I hope you can help me.

>What is the simplest way to avoid the
>error 49 "Data segment too large".

Use pointers.  :-)

Seriously, though, convert your static structures (var thing:array[1..64000] of
byte) to pointers, like this:

type
  arraytype=array[1..64000] of byte;

var
  thing:^arraytype;

Look up new() and dispose() or getmem() and freemem() for more info.
--
Jim Leonard                                             Email: trix...@mcs.com
(Tricks of the Trade Digitizing Services, and also Trixter of Hornet)
*THE* PC Demo WWW page:  http://www.cdrom.com/pub/demos/hornet/html/demos.html

Re:Data segment too large


Quote
> What is the simplest way to avoid the
> error 49 "Data segment too large".

   The _simplest" way is to reduce the amount of Var data which is being
linked into the program - that's what the error is telling you: you have
somehow caused more than 64K bytes of Var data to be referenced (and
linked into the program).  There are several things you can do (many of
which we've done at one time or another):
  1. Reduce the size/dimensions of your defined structures.  This can
entail such things as: using specific-length strings (string[n], rather
than string); reduce array dimensions; use Byte arrays instead of
integer/Word arrays (or use bit arrays instead of Byte arrays for
flags), etc.
  2. Establish multiple Var blocks in your global Units, so that only
truly refenerced Var data is linked into specific programs.  Note that a
Unit which has 1 Var block of, say, 30K will link _all_ of that 30K into
the Data Segment of a program which references only 1 variable in that
Var block - the Smart Linker can't determine what of that Var block
isn't actaully being used.  So, realign/block your Units' Var data in
some "application-specific" order, so that all/most of what's linked
into a given program is actually referenced.  This will take
time/effort, but the payoff is major...
  3. Use Pascal pointers to allocate/access large data structures: a
pointer to a 300 byte structure consumes only 4 bytes of your (precious)
Data Segment and 304 bytes of Heap space - of which you probably have
about 400k to use - rather than 300 bytes of Data Segment...a big
savings any time you can do this.
  4. Use the Stack and procedure-local data for data which is used only
by procedures.  You have (up to) 64K of Stack, so it's possible to
almost double the 64K of Var data by clever use of procedure-local and
global data.
   So, there's much you can do, yet little of it is either easy or
simple - you really must restructure your program's Data, usages, sizes
and locations.  It's a good idea to obtain a .MAP file from your
(successful) compile/link, to examine what Data is being brought into
your program and from where...

Re:Data segment too large


Quote
>   1. Reduce the size/dimensions of your defined structures.  This can
> entail such things as: using specific-length strings (string[n], rather

...

PChar works for me - it takes the length of the actual string without
255 padding characters so you can have strings of varying length
without having to separate them for the sake of size.

Quote
>   2. Establish multiple Var blocks in your global Units, so that only

...
?? I thought the linker eliminated "dead" code and data.
That's a good idea - I learned something here today.

Quote
>   3. Use Pascal pointers to allocate/access large data structures: a
> pointer to a 300 byte structure consumes only 4 bytes of your (precious)

...
Yes, I use this for screen buffering. The explanation wasn't too
good though, you use getmem(pointer,size) and then freemem(pointer,size)

Quote
>   4. Use the Stack and procedure-local data for data which is used only
> by procedures.  You have (up to) 64K of Stack, so it's possible to
> almost double the 64K of Var data by clever use of procedure-local and
> global data.

...
Just don't go overboard, a stack overflow sometimes means full
system crash :)

--
--------------------------------------------------------------
/------\/-----\/-----\/-\  /-\/------\/-----\/-----\/---\  /-\
\| /-\ || /-\ || /-\ || | /  /| /\/\ || /-\ || /-\ ||    \ | |
 | | | || \_/ || \_/ || |/ /_ | |||| || | | || | | || |\  \| |
 | | | || /-\ || /-\| | /-\  || |\/| || | | || | | || | \  \ |
/| \-/ || | | || | | \| | |  || |  | || \_/ || \_/ || |  \   |
\______/\_/ \_/\_/ \_/\_/ \__/\_/  \_/\_____/\_____/\_/   \__/
--------- http://connexus.apana.org.au/~mikuto/darky ---------

Other Threads