🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.pascal.ansi-iso
6 messages
6 total messages Started by Doug Williams Tue, 18 Jun 1996 00:00
## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)
#25
Author: Doug Williams
Date: Tue, 18 Jun 1996 00:00
18 lines
1435 bytes

During compile, I am getting error 49 Data Segment to large.
In my Uses section of my program I have the following:



Uses dos,crt,support,menubox,objects;

The latter 3 are my tpu's.



In help, it says to create a pointer to objects to lower the 
data segment or something.  If anyone understands how to 
correct this problem or my spelling I would sure appreceate it.

Doug 
Re: ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)
#26
Author: Clement
Date: Wed, 19 Jun 1996 00:00
22 lines
1690 bytes
Doug Williams wrote:
> 
> During compile, I am getting error 49 Data Segment to large.
> In my Uses section of my program I have the following:
> 
> Uses dos,crt,support,menubox,objects;
> 
> The latter 3 are my tpu's.
> 
> In help, it says to create a pointer to objects to lower the
> data segment or something.  If anyone understands how to
> correct this problem or my spelling I would sure appreceate it.
> 
> Doug

Doug,

I don't know which model are you using. If you are not using HUGE model,
try to use it.

Clement
Re: ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)
#27
Author: Ron Muzzi
Date: Wed, 19 Jun 1996 00:00
43 lines
2745 bytes
will-cib@digital.net (Doug Williams) wrote:

>During compile, I am getting error 49 Data Segment to large.
>In my Uses section of my program I have the following:
>
>
>
>Uses dos,crt,support,menubox,objects;
>
>The latter 3 are my tpu's.
>
>
>
>In help, it says to create a pointer to objects to lower the 
>data segment or something.  If anyone understands how to 
>correct this problem or my spelling I would sure appreceate it.
>
>Doug 
>

There are a few things you can do:

First, go through your variables (because these get stored in the data segment) 
and make sure that you are not wasting space.  For example, "string" uses 
256 bytes of space.  It's better to use "string[n]" where n is the actual
max size of your string.  You will also want to define some types of these
shorter strings to be used in procedure/function calls.

Second, use the heap for variable space.  Read in your manual how to use the 
heap.  It involves using GetMem, New, Dispose, etc.  A pointer is used to access
variables created on the heap.  (That's what the error explanation is referencing.)
The pointer will be in the data segment, but the heap uses all other available 
memory.  Therefore, it is good for records, strings, arrays, etc.  The other 
advantage of the heap is that you allocate memory for your variables during 
runtime and you can deallocate the space when you are done with it.

Let us know if you have any other questions.

Ron Muzzi, EE
Great Lakes Environmental Research Lab
Ann Arbor, Michigan, USA
muzzi@glerl.noaa.gov
Re: ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)
#28
Author: Mike Copeland
Date: Wed, 19 Jun 1996 00:00
42 lines
3559 bytes
> > During compile, I am getting error 49 Data Segment to large.
> > In my Uses section of my program I have the following:
> >
> > Uses dos,crt,support,menubox,objects;
> >
> > The latter 3 are my tpu's.
> >
> > In help, it says to create a pointer to objects to lower the
> > data segment or something.  If anyone understands how to
> > correct this problem or my spelling I would sure appreceate it.
> > 
> I don't know which model are you using. If you are not using HUGE model,
> try to use it.

   There is no declaration of Model in TP/BP - I believe that's only for 
C/C++ - and that's not an appropriate solution to his problem.  This 
error, all too common for new Pascal programmers, is caused by the 
programmer declaring too much Var data within the total components of 
his/her program: main program _and_ Units.  TP/BP limits the target 
program to 64K of Var data (the Data Segment), and the solution to this 
error only involves reducing the Var data which is used/bound into the 
target program.  There are many ways to do so:
  - Reduce the size of large data structures, such as arrays, records, 
strings (use specific-size strings, rarher than "string"), etc.
  - Create multiple Var blocks in Units, so that the Smart Linker won't 
link _all_ of the Unit data, even though it's not referenced bny the 
program.  This invaluable step requires analysis of the applications 
which use the Unit, so that data is organized in a fashion associated 
with the using programs.  This process can significantly reduce the 
amount of Var data linked into any given program...and should always be 
done for "global" Units.  TP/BP Smart Linking will bind into the target 
program only _referenced_ subprograms and data, so the total amount of 
subprograms and global data in a Unit can be enormous, so long as the S/L 
has a way to exclude components which aren't referenced by a program or 
another Unit.
  - Declare some procedure-local data in the subprogram code, so that 
such data is allocated on the Stack, rather than on the Data Segment.
  - Use Pascal pointers to reference large data structures, and allocate 
that data on the Heap.  This is the most commonly recommended solution, 
but it requires knowledge of and experience with Pascal pointers 
(something which should be done in any case...).
Re: ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)
#29
Author: sv
Date: Fri, 21 Jun 1996 00:00
36 lines
1999 bytes
On 18 Jun 1996 23:39:39 GMT, will-cib@digital.net (Doug Williams)
wrote:

The problem is not the memory model as you can define in C or ASM.
(as the other one 'said').

You can only make arrays and strings up to a maximum of 64kb, so the
problem is most likely not in your tpu-files but in what follows some
lines below, your variables.

No corrections possibly, and if you are serious about programming, you
have no option but to learn how pointers work.

Got it ?


You wrote:
>
>During compile, I am getting error 49 Data Segment to large.
>In my Uses section of my program I have the following:
>
>
>
>Uses dos,crt,support,menubox,objects;
>
>The latter 3 are my tpu's.
>
>
>
>In help, it says to create a pointer to objects to lower the 
>data segment or something.  If anyone understands how to 
>correct this problem or my spelling I would sure appreceate it.
>
>Doug 
>
Re: ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)
#30
Author: Peter Knoerrich
Date: Mon, 24 Jun 1996 00:00
63 lines
3088 bytes
sv_sw@kiruna.se (sv) writes:

>During compile, I am getting error 49 Data Segment to large.
>In my Uses section of my program I have the following:
>
>Uses dos,crt,support,menubox,objects;
>
>The latter 3 are my tpu's.
>
>In help, it says to create a pointer to objects to lower the 
>data segment or something.  If anyone understands how to 
>correct this problem or my spelling I would sure appreceate it.
>
>Doug 

Turbo Pascal will only handle 64kB of global variables in the data
segment (that's everything outside any function from all the units
plus the main program file).

You can however sometimes use some STACK space for temporary larger
data structures and variables: Try to move your larger buffers from
global definitions to local ones. Local variables go to a separate
64kB stack segment and also stop taking up space once the procedure
defining them ends.

type BIGTYPE = array[0..10000] of integer;
var BIG : BIGTYPE;
procedure berk;
begin
  /* BIG used here */
end;

vs.

type BIGTYPE = array[0..10000] of integer; /* doesn't take space so stays */
procure berk;
var BIG : BIGTYPE;  /* Goes to the stack now */
begin
  /* BIG used here */
end;

You'll probably need to pass references to BIG to procedures called
by berk if they need to access BIG:

procedure called_by_berk(var BIG : BIGTYPE);

This allows for up to another 64kB of data. Last resort is pointers.
For variables which don't change their size that can be pretty simple
though:

type BIGTYPE = array[0..10000] of integer;
var BIG : ^BIGTYPE;
begin /* of main program */
  New(BIG,sizeof(BIGTYPE));  /* Oh gosh I hope this works - no help online here! */
  /* Now, where you used BIG before, use BIG^ . */
  Dispose(BIG); /* optional cleaning up. Makeup. DON'T use BIG^ afterwards. */
end;

Hmm, if it don't work ask again, I'll check with TP help then. Boy you'd not think
memory fades that fast. 

Peter.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads