Board index » delphi » Program-size limit!

Program-size limit!


I've heard there's a limit on how big a TP-program can be, 65k I think.
Is this correct?
If so, I believe I have to use pointers. How am I to do that? I'm NOT good at

Please reply anything I've soon reached 65k...


"Hey, no brain, but what the heck!?"


Re:Program-size limit!

In article <4guf8n$> (Baudkern) writes:
>I've heard there's a limit on how big a TP-program can be, 65k I think.
>Is this correct?

Not quite.  The program itself can be as big as you need it, as long as no
code segment exceeds ~64K (65536-8 bytes).  Each unit has its own code
segment, and you can usually add as many units as you need.

OTOH, what you may be thinkin of is *data*.  Between the data segment (all
preset variables and global variables) and the stack segment (for local
variables and parameter passing), you're limited to 64K.

>If so, I believe I have to use pointers. How am I to do that? I'm NOT good at
>Please reply anything I've soon reached 65k...

In that case, you'd better learn pointers!  Your User's Guide from your
TP/BP manuals should have a chapter about pointers.  Also, you might look at
Glenn Grotzinger's (hope I got that right!) TP tutorials at
for some useful explanations.  Or just post some questions that'll help you
figure 'em out!

>"Hey, no brain, but what the heck!?"

Scott F. Earnest             |0100100001000001010010010100110000100000|   |0100010101010010010010010101001100100001|
Head Pope, Non-Extant Temple of Afrodite, Goddess of Funky 70's Hairdos -><-
      YOU'VE BEEN LIED TO:  Possession is only one tenth of the law.
                The other nine tenths is really STUPIDITY!

Re:Program-size limit!

In a previous article, Ove B?ck <> wrote:

>Your EXE can be as big as you like it (as big as you can make it), but the size of your
>local variables are limited to your stack (normally 16K). If you need more than that,
>you'll have to use pointers.

If sure you meant to say "globals" where you used "locals" above, but
regardless ...

Don't forget that you stack can be increased up to 64K with the
{$M StackSize,HeapMin,HeapMax} compiler directive.

However, something is seriously wrong with most programs if they even need
16K of the stack for storing variables - it is generally a good idea to
conserve stack space as much as possible for uses other than mere data storage.
Your data can always go on the heap - all the data that ever HAS to go on the
stack is a few pointers to heap locations of where your data actually is -
but just about everything else that needs to use the stack has no place else
to go.

The exceptions to the "generally" in the paragraph above usually involve
programs that are very simple and don't use recursions (which can eat up
stack space faster than your girlfriend can cover your bathroom counter-top
with her make-up containers ) and hence don't risk anything by using lots
of stack space for data storage.


Re:Program-size limit!

                                                 29 Feb 96

 Hi folks, (Baudkern)  wrote on 27.02.96 at
 /COMP/LANG/PASCAL/BORLAND under the topic of "Program-size limit!"
 (MsgID: 4guf8n$

 e> I've heard there's a limit on how big a TP-program can be, 65k I think.
 e> Is this correct?

 No, it is not correct. One segment cannot exceed the size of 64kB but
 that's no problem. Every Unit uses one extra segment of code, so if you
 are running out of space cut your program into pieces of units. Thats
 the best way to do maintenance on turbo pascal programs anyway. And
 only units can be used as overlays.

 The only problem can be the data segments. There is exactly one data
 segment and one stack segment of 64kB each. If you  haven't enought
 space at your data segment you have to use dynamic data (-> pointers).

 Any further questions? Mail me :-)



Re:Program-size limit!

In article <4i1hic$> writes:
>On 29 Feb 1996 07:50:01 -0700, (Sundial Services)
>>As you mentioned, the program's data segment and/or stack segment is also
>>limited to 64K, and here the solution is to allocate objects on the heap and
>>to use pointers to reference them.  Things are much simpler with code -- and
>>frankly, I sometimes wonder what would have been so difficult about making
>>data work the same way.  :-/  
>Data *does* work the same way.  Local data is limited, but not the
>total amount of data in the program.

Well, static data for the entire program *is* limited to one segment.  It
would be nice to have multiple data segments, but this can slow down a
system, because you every procedure would have to reload DS, and the fastest
way (I think) is to have each procedure reload, whether it's redundant or
not (checking DS would add even more overhead).

In practical terms, there's a limit to everything.  ;-)

>Of course for *global* data . . .
>We just started to redesign our program so that global data is
>allocated on the heap for just that reason.  We needed 5 more bytes
>than allowed.  Anyone have a shoehorn?

Typically, what I do if there's a large block of global data, I just dump it
to a file, run it through BINOBJ, link it to my program and build a pointer
to it when I need it.  So, in effect, you have static data, but it resides
in one of a program's potentially many code segments.  And if I want to
twiddle the data under protected mode, I can just put space on the heap and
copy it over (you can't write to a code segment in PM).

Um, BTW, just *how* would you allocate *global* data on the heap, when it
should already be in the data segment?  Did you load it from a file?


Scott F. Earnest           | "I never had a life.  I don't even know what | life is." . . . "I have what you'd call a
Life sucks, wear a helmet. | life."  -- Ministry / "Crumbs" / Filth Pig

Other Threads