Board index » delphi » Help: Data Segment too large

Help: Data Segment too large

I'm using TP6.0 to update a program I wrote some time ago that simply displays
a series of ANSI files. Now I'm trying to include the ANSI data in the .exe
file itself and I get a compile error #49: Data Segment too large. The manual
says this about the error:

    The maximum size of a program's data segment is 65,520 bytes, including
    data declared by the used units. If you need more global data than this,
    declare the larger structures as pointers, and allocate them dynamically
    using the New procedure.

I understand pointers fairly well, but still cannot make any sense out of the
statement above. Could someone please give me a brief example of what this
means, i.e., how to stuff a lot of text data into my .exe file? Please respond
by email. Thank you!

Paul

 

Re:Help: Data Segment too large


Quote
> I'm using TP6.0 to update a program I wrote some time ago that simply displays
> a series of ANSI files. Now I'm trying to include the ANSI data in the .exe
> file itself and I get a compile error #49: Data Segment too large. The manual
> says this about the error:

>     The maximum size of a program's data segment is 65,520 bytes, including
>     data declared by the used units. If you need more global data than this,
>     declare the larger structures as pointers, and allocate them dynamically
>     using the New procedure.

> I understand pointers fairly well, but still cannot make any sense out of the
> statement above. Could someone please give me a brief example of what this
> means, i.e., how to stuff a lot of text data into my .exe file?

   The error message is only telling you the compiler/linker can't
produce a data Segment which is <=64K...and that you've declared too
much Var data in your program and referenced Units.  It's also
suggesting that you convert some of thos Vars - specifically large
structure declarations - to pointers to those Types and allocate the
data on the Heap - with New or GetMem.
   I don't know how appending external data to the .EXE has any impact
on this problem - you won't have an EXE file to do this to/with _until_
the program compiles and links...you're not there yet.
   You must look at all Vars in your source(s) and reduce them somehow:
cut down the dimensions of arrays, use specific-size strings instead of
"string", move some of the data into procedure-local declarations,...and
probably convert some structure variable(s) to pointer references.  This
is a very common proble in TP/BP, are these are the general techniques
required to deal with it.

Re:Help: Data Segment too large


Quote
thin...@cjnetworks.com (Paul Bryant) wrote:
>I'm using TP6.0 to update a program I wrote some time ago that simply displays
>a series of ANSI files. Now I'm trying to include the ANSI data in the .exe
>file itself and I get a compile error #49: Data Segment too large. The manual
>says this about the error:

>    The maximum size of a program's data segment is 65,520 bytes, including
>    data declared by the used units. If you need more global data than this,
>    declare the larger structures as pointers, and allocate them dynamically
>    using the New procedure.

>I understand pointers fairly well, but still cannot make any sense out of the
>statement above. Could someone please give me a brief example of what this
>means, i.e., how to stuff a lot of text data into my .exe file? Please respond
>by email. Thank you!

>Paul

What it says is, that you can't have it all in the global data part of
your EXE file, called the data segment, because there is a limit to
the amount of data that can be stored in it. This includes all global
variables and typed constants in the main program and in the interface
sections of the units it uses.

It also says that you can have more global data when you dynamically
allocate memory for it on the heap, using the new procedure, and free
that memory using dispose when the program doesn't need it any longer.
But then you still would have to copy the data to the allocated heap
memory from somewhere at run time, and since it doesn't fit in the
data segment the obvious way would be to read it from an external
file. But this is what you already do now, so it wouldn't get you any
further.

There may be more ways to cope with this problem, but I think you
could use overlays here. In order to use this technique, you declare
the ANSI data in separate units and specify them as overlays (the
manual will teach you how). That way, you can access them one at a
time and not simultaneously, but from what I understand that's not a
problem in your the situation. The compiled EXE file will contain all
data.

Bob Ferguson.

-----------------------------------------
J.R. Ferguson, Amsterdam, The Netherlands
e-mail: j.r.fergu...@iname.com
web: www.xs4all.nl/~ferguson
Freeware for DOS and Windows

Re:Help: Data Segment too large


In article <32eb4736.4599...@news.xs4all.nl>,

Quote
J.R. Ferguson <j.r.fergu...@iname.com> wrote:
>It also says that you can have more global data when you dynamically
>allocate memory for it on the heap, using the new procedure, and free
>that memory using dispose when the program doesn't need it any longer.

If the data is really global then there is no point in disposing it. Dos
will deallocate entire program, including heap, when the program ends.

Osmo

Re:Help: Data Segment too large


Quote
ronka...@cc.helsinki.fi (Osmo Ronkanen) wrote:
>In article <32eb4736.4599...@news.xs4all.nl>,
>J.R. Ferguson <j.r.fergu...@iname.com> wrote:
>>It also says that you can have more global data when you dynamically
>>allocate memory for it on the heap, using the new procedure, and free
>>that memory using dispose when the program doesn't need it any longer.

>If the data is really global then there is no point in disposing it. Dos
>will deallocate entire program, including heap, when the program ends.

>Osmo

True, but the original question was about how to access LOTS of global
memory from roughly one hundred separate data items that are to be
used one-by-one in an application that is to be distributed to many
users. Since there is also a limit to the installed amount of heap
memory, and this limit is not the same for each user of the
application, it seems adviseable to dispose of allocated heap memory
as soon as it's feasible.

Bob Ferguson.

-----------------------------------------
J.R. Ferguson, Amsterdam, The Netherlands
e-mail: j.r.fergu...@iname.com
web: www.xs4all.nl/~ferguson
Freeware for DOS and Windows

Other Threads