ERROR # XX ,DATA SEgment is too large 
Author Message
 ERROR # XX ,DATA SEgment is too large

Hi guys, I need some help againg.
I wrote a kick ass Communication package for dos (even better than
Qmodem pro) and decided to add few little functions just to enchance the
package.  and guess what? Now it won't compile telling me that Data
Segment is too large.  The project is over 5000 lines at the moment and
won't compile.  i tryed keeping all variables local and stay away from
globals, I split major parts into units.  Still... Damn thing running
out of memory.  Any suggestions? HELP!!!! ;(

now, I also have a broland c++ 3.0 installed on my machine.  How hard is
it to port the application to C++ if its about 505 basm?  Does c++ have
any size limits?

Please respond ASAP!!!

------------------------------------------------------------------------
You will be charged $500 dollar fee for every adverti{*filter*}t/commercial
mail sent to my mailbox.  If you disagree with my policy, DO NOT SEND me
any mail.  By sending me mail you agree to abide by all U.S.
Telecommunications laws, including and not limited to not sending
solicited email, copyrighted material or other illegal type of
information.  If the terms have been violated you will be prosecuted!  
------------------------------------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 ERROR # XX ,DATA SEgment is too large

Quote:

> Hi guys, I need some help againg.
> I wrote a kick ass Communication package for dos (even better than
> Qmodem pro) and decided to add few little functions just to enchance the
> package.  and guess what? Now it won't compile telling me that Data
> Segment is too large.  The project is over 5000 lines at the moment and
> won't compile.  i tryed keeping all variables local and stay away from
> globals, I split major parts into units.  Still... Damn thing running
> out of memory.  Any suggestions? HELP!!!! ;(

Well, you only have a little less than 64KB of global data to work with,
and if you're having problems, you apparently still have a lot of global
variables declared.  Note that if you also have a lot of typed
constants, those are also stored in the data segment.  I *think* (but
don't recall 100%) that string literals, if any, are stored along in the
code segment, so I don't think that should be a problem.

Quote:
> now, I also have a broland c++ 3.0 installed on my machine.  How hard is
> it to port the application to C++ if its about 505 basm?  Does c++ have
> any size limits?

By 505, you mean 50%?  Maybe, maybe not.  In the huge model, you can
have multiple data segments at the expense of a slight loss of
efficiency (DS gets reloaded on global data operations).  That may
require some of the assembly to be modified to work.  Also, C and TP use
different calling procedures, and you'll have to declare your C++ code
procedures as Pascal.

Quote:
> Please respond ASAP!!!

--
Scott Earnest        | We now return you to our regularly |



Wed, 18 Jun 1902 08:00:00 GMT  
 ERROR # XX ,DATA SEgment is too large

Quote:

> Hi guys, I need some help againg.
> I wrote a kick ass Communication package for dos (even better than
> Qmodem pro) and decided to add few little functions just to enchance the
> package.  and guess what? Now it won't compile telling me that Data
> Segment is too large.  The project is over 5000 lines at the moment and
> won't compile.  i tryed keeping all variables local and stay away from
> globals, I split major parts into units.  Still... Damn thing running
> out of memory.  Any suggestions? HELP!!!! ;(

I had this same problem when writing an IRC Client.

*ALL*  VAR's go into one segment and segments are 64k in size.  This
segment is called the Data Segment.   Large Array's really eat up this
small amount of memory VERY quickly.   To solve this you can make sure
you allocate some heap space

{$M 16384, $4000, $8000}

16384 is stack size (this may need to be adjusted if the program crashes
because there isn't enough).   $4000 is going to be the minimum size of
the heap (if it can't have it I doubt the program will run),  $8000 is
the maximum size of the heap (32768 bytes or so).

Change the variables to Pointer types by going:

TYPE   ExTypeOne = Array[0..50] of String[80];

Var   ExOne : ^ExTypeOne;

Now you have to make that pointer ExOne point to a variable of type
ExTypeOne which can be done easily by going:

New(ExOne);

To Use the array it is used by going:
ExOne^[1] := 'Testing';
ExTwo^[2] := 'Testing Some More';
Writeln(ExOne^[1]);
Writeln(SizeOf(ExOne^));

MemAvail is a function that returns the HEAP memory available.

Dispose(ExOne);   should be called when the program exits.

At the end part of most of my units I have something like:

{$F+}
var SaveExitProc : Pointer;

Procedure ThisUnitsNameExitProc; far;
Begin
  ExitProc:=SaveExitProc;
  Dispose(ExTwo);
  Dispose(ExOne);
End;

BEGIN
  SaveExitProc:=ExitProc;

  New(ExOne);
  New(ExTwo);  {etc... for the variables you want on the heap}
END.  

I don't know if this is efficient or necessary to actually Dispose() the
variables when you exit, but I do anyhow.    Within the program memory
can be saved for some sections by Dispose()ing unneeded variables and
New()ing them again afterwards (note that the data in those variables
will be lost though).

     Create a .MAP file (using -GS if using TPC) and it will show you how
large the Data Segment is (this will require that it is already compiling
mind you).  If the Size of it is over F000 then there isn't much room for
more variables (by changing most of my large arrays to variables on the
heap I went from FC00 or so A100).

--

  Programmer:  Author of TP7.0 Units for Trumpet TCP/IP, TimeZone, jpIRC

| PGP Info: 2048/A8A1DCD5 : E0 9E 9B EF C8 E4 68 3D  B5 9C 72 4C EC 61 DD 7A |



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Error 49, Data segment too large

2. Static data size/data segment to large

3. Data Segment too large

4. data segment too large?

5. Data segment too large

6. Data segment too large

7. Help: Data Segment too large

8. Borland Pascal for Windows. Data segment too Large

9. Data segment too large

10. Data Segment to Large

11. Data Segment to Large

12. 49: Data Segment Too Large

 

 
Powered by phpBB® Forum Software