## HELP ## with Turbo Pascal 7.0 (Compiler Error 49) 
Author Message
 ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)

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



Sat, 05 Dec 1998 03:00:00 GMT  
 ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)

Quote:

> 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



Sun, 06 Dec 1998 03:00:00 GMT  
 ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)

Quote:

>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



Sun, 06 Dec 1998 03:00:00 GMT  
 ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)

Quote:
> > 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...).


Sun, 06 Dec 1998 03:00:00 GMT  
 ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)



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 ?

Quote:

>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



Tue, 08 Dec 1998 03:00:00 GMT  
 ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)

Quote:

>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.



Fri, 11 Dec 1998 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. ## HELP ## with Turbo Pascal 7.0 (Compiler Error 49)

2. Error 49

3. Error 49, Data segment too large

4. TP6: mem-shortage [compile error 49]

5. I NEED TURBO PASCAL 7.0 HELP FILE (TURBO.TPH)

6. I would like to know the difference between Borland Pascal 7.0 and Turbo Pascal 7.0

7. Turbo Pascal 7.0 vs Borland Pascal 7.0

8. Help with Turbo Pascal 7.0

9. Help!! with Turbo Pascal 7.0

10. HELP ME!!!!!! ASCII Characters in Turbo Pascal 7.0

11. Turbo Pascal 7.0 IDE Help!!!

12. How might I get Turbo Pascal 7.0 and Turbo Debugger 4.6 to play together

 

 
Powered by phpBB® Forum Software