Subject: 64k limit ?????? data segment error .... 
Author Message
 Subject: 64k limit ?????? data segment error ....


Quote:


>>>You can :

>>>1) Split the data into different units.

>>This must me one of the most common false advices in this group. It does
>>not help as the data segment is global.

Pardon my french, but that us bull.

--

 "How do you shoot the devil in the back?"
 "What if you miss?" -Verbal Kint
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



Mon, 13 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....


writes

Quote:



>>>>You can :

>>>>1) Split the data into different units.

>>>This must me one of the most common false advices in this group. It does
>>>not help as the data segment is global.

>Pardon my french, but that us bull.

BP & TP have *one* data segment that is limited to 64K at max. If you
want more variables you *do* need to use the heap, in TP/BP.

Note: I'm assuming TP/BP Compiler as this is X-Posted to c.l.p.b

Quote:
>--

> "How do you shoot the devil in the back?"
> "What if you miss?" -Verbal Kint
>=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Duff SigSep (SigSep = "Dash" "Dash" "Space")
--

In principle,   is there uncertainty that
Heisenberg was working his best in chaos?
=========================================



Mon, 13 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....



Quote:

>> Q: How can I use the heap?
>> A: Memory on the heap can only be accessed with pointers.
>>    Try this example, then adapt the principle to your programs:
>>    type
>>       arr    = array [1..30000] of longint; { this is your data }

         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Quote:
>>       arrptr = ^arr;                  { that's a pointer to the data }
>>    var
>>       data : arrptr;       { this is such a pointer variable }
>>    begin
>>       if memavail < sizeof(arr) then halt;

*only* works is your are using a 32 bit compiler. As X-Posted to c.l.p.b
I assume that your are using TP/BP product - neither work in 32 bit mode
& segements are limited to 64K.
--

In principle,   is there uncertainty that
Heisenberg was working his best in chaos?
=========================================



Mon, 13 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....

Hallo,

wo gibt's bitte die 32bit Pascal Compiler (lagernd), die Arrays gr??er
64kByte beherrschen.

danke
Gerfried



Quote:

> : I`m getting a "data segment too large" error and I think it`s because
I`m
> : over the 64k limit.

> Borland Pascal 64k Limit FAQ
> ----------------------------



Mon, 13 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....



Quote:
>Hallo,

>wo gibt's bitte die 32bit Pascal Compiler (lagernd), die Arrays gr??er
>64kByte beherrschen.

>danke
>Gerfried

In der FAQ, Klaus Hartnegg hat schreibt :

Q: What about other Pascal compilers?
A: Check FPK-Pascal and GNU-Pascal.
   Both are free 32-bit Pascal compilers available for DOS
   that are more or less Borland compatible.
   If you want a Pascal compiler for Linux or OS/2, the two same
compilers
   are available for these operating systems too plus a few more, see
   http://www.brain.uni-freiburg.de/~klaus/pascal/web-list.html
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

--

In principle,   is there uncertainty that
Heisenberg was working his best in chaos?
=========================================



Mon, 13 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....

Quote:

> Then I tested this:
> ---------------------------------------------------
> Unit Test1;
> Interface
> Var array1: Array[0..65535] of byte;
> Implementation
> End.
> ---------------------------------------------------
> Unit Test2;
> Interface
> Var array2: Array[0..65535] of byte;
> Implementation
> End.
> ---------------------------------------------------
> Program Testit;
> Uses Test1,Test2;
> Var Counter : Word;
> Begin

> End.
> ---------------------------------------------------

> Ok.. This compiles nicely.. and so it does if you use one of the
> arrays..

Try:

Program ReallyTestIt;
Uses Test1, Test2;
Begin
Array1[1] := 1;
Array2[1] := 1;
End.

If you don't use a variable, it gets stripped by the smart linker.

In any case, I got "Structure too large" when compiling the units. I
know how to get around this, but decided that changing the range of the
arrays to 0..40000 would still prove the point. Result: "Error 49: Data
segment too large."

[Disclaimer: We're talking about Turbo/Borland Pascal here. None of this
thread seems to apply to the snazzy new 32-bit compilers.]

AME



Mon, 13 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....


Quote:
>In any case, I got "Structure too large" when compiling the units. I
>know how to get around this, but decided that changing the range of the
>arrays to 0..40000 would still prove the point. Result: "Error 49: Data
>segment too large."
>[Disclaimer: We're talking about Turbo/Borland Pascal here. None of this
>thread seems to apply to the snazzy new 32-bit compilers.]

What I do to deal with all of this, quite simply, is to use a Delphi class
with an array-style "read" and "write" method. The source-code that I write
becomes the same as if the object in question really was an array.  What
actually happens is up to me.

Many programmers weaned on Visual Basic assume that VB's arrays are somehow
exempt -- that they have "solved" the problem.  But in fact what the VB
interpreter does (and does not allow you to change) is essentially what you
are doing here -- 'cept you can change it.  A data-structure other than a flat
contiguous block of memory *is* being used.



Mon, 13 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....



Quote:



>>> Q: How can I use the heap?
>>> A: Memory on the heap can only be accessed with pointers.
>>>    Try this example, then adapt the principle to your programs:
>>>    type
>>>       arr    = array [1..30000] of longint; { this is your data }
>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>       arrptr = ^arr;                  { that's a pointer to the data }
>>>    var
>>>       data : arrptr;       { this is such a pointer variable }
>>>    begin
>>>       if memavail < sizeof(arr) then halt;

>*only* works is your are using a 32 bit compiler. As X-Posted to c.l.p.b
>I assume that your are using TP/BP product - neither work in 32 bit mode
>& segements are limited to 64K.

This is not true. Declaring a type does not allocate memory. So the above
example is perfectly legal even for 16-bit OS's.

Babis Athineos

--

WWW : http://users.hol.gr/~babis
S-mail: Papadoniou 61, 11145 Athens, Greece



Tue, 14 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....



Quote:



>>> Q: How can I use the heap?
>>> A: Memory on the heap can only be accessed with pointers.
>>>    Try this example, then adapt the principle to your programs:
>>>    type
>>>       arr    = array [1..30000] of longint; { this is your data }
>         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>       arrptr = ^arr;                  { that's a pointer to the data }
>>>    var
>>>       data : arrptr;       { this is such a pointer variable }
>>>    begin
>>>       if memavail < sizeof(arr) then halt;

>*only* works is your are using a 32 bit compiler. As X-Posted to c.l.p.b
>I assume that your are using TP/BP product - neither work in 32 bit mode
>& segements are limited to 64K.

This is not true. Declaring a type does not allocate memory. So the above
example is perfectly legal even for 16-bit OS's.

Of course a correction must be made in MemAvail: it should be MaxAvail,
as Alan Evans first said.

Babis Athineos

--

WWW : http://users.hol.gr/~babis
S-mail: Papadoniou 61, 11145 Athens, Greece



Tue, 14 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....

Quote:
>>Pardon my french, but that us bull.

>BP & TP have *one* data segment that is limited to 64K at max. If you
>want more variables you *do* need to use the heap, in TP/BP.

I KNOOOOW! .. argh! .. :) .. (thats supposed to be "is bull" even)
I tested it, and I where wrong.

--

 "How do you shoot the devil in the back?"
 "What if you miss?" -Verbal Kint
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



Tue, 14 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....


Quote:
>> Ok.. This compiles nicely.. and so it does if you use one of the arrays.. As
>> soon as you try to poke something into the 65536'th byte though, you get a "data
>> segment too large" error.. I fold. I was pretty sure it was possible, but I
>> havent used this way of "memory allocation" in ages. hehe..

>   This test of yours, while it may _compile_, isn't at all valid - none
>of the Var declarations in the Units is linked into the program, since
>there are no _references_ to any of the data.  Apparently you don't
>understand the concept of the Data Segment, Unit vars, scoping, or how
>the Smart Linker works  - and all you've done here is compile a "dummy"
>program which has no data whatsoever.  So your point is moot.

I suggest you read my statement again. Read the whole thing this time. That it
will (hopefully) become obvious to you that I ofcourse tried to USE the data
aswell. Read it again please.

--

 "How do you shoot the devil in the back?"
 "What if you miss?" -Verbal Kint
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



Tue, 14 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....



Quote:
>................
>Program Testit;
>Uses Test1,Test2;
>Var Counter : Word;
>Begin

>End.
>---------------------------------------------------

>Ok.. This compiles nicely.. and so it does if you use one of the arrays.. As
>soon as you try to poke something into the 65536'th byte though, you get a "data
>segment too large" error.. I fold. I was pretty sure it was possible, but I
>havent used this way of "memory allocation" in ages. hehe..

I'm afraid, Kim, you didn't remember to use BOTH the arrays in the
program, so you left the smart linker eliminate the never-used array...
In this case the linker was not smart enough to guess your purpose! :)

I suggest you do a little more reading on medium memory model which is
used by BP.

Babis Athineos

--

WWW : http://users.hol.gr/~babis
S-mail: Papadoniou 61, 11145 Athens, Greece



Tue, 14 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....

Quote:






> >>> Q: How can I use the heap?
> >>> A: Memory on the heap can only be accessed with pointers.
> >>>    Try this example, then adapt the principle to your programs:
> >>>    type
> >>>       arr    = array [1..30000] of longint; { this is your data }
> >         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >>>       arrptr = ^arr;                  { that's a pointer to the data }
> >>>    var
> >>>       data : arrptr;       { this is such a pointer variable }
> >>>    begin
> >>>       if memavail < sizeof(arr) then halt;

> >*only* works is your are using a 32 bit compiler. As X-Posted to c.l.p.b
> >I assume that your are using TP/BP product - neither work in 32 bit mode
> >& segements are limited to 64K.

> This is not true. Declaring a type does not allocate memory. So the above
> example is perfectly legal even for 16-bit OS's.

> Of course a correction must be made in MemAvail: it should be MaxAvail,
> as Alan Evans first said.

Well, at least tp6 and tp7 checks to see if the array is >64k, and
halt's with
and "Structure too large" error if it is...

--
- Asbj?rn / Lord Crc

http://home.sn.no/~bheid/



Fri, 17 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....


Quote:
>>Ok.. This compiles nicely.. and so it does if you use one of the arrays.. As
>>soon as you try to poke something into the 65536'th byte though, you get a "data
>>segment too large" error.. I fold. I was pretty sure it was possible, but I
>>havent used this way of "memory allocation" in ages. hehe..

>I'm afraid, Kim, you didn't remember to use BOTH the arrays in the
>program, so you left the smart linker eliminate the never-used array...
>In this case the linker was not smart enough to guess your purpose! :)

ARGH!!!! youre the 5th person to say this... READ MY POST! I had two arrays,
both of 65535 bytes. And I said: "As soon as I poked into byte 65536" .. Now,
that would mean that the second I used BOTH arrays, wouldnt it?

--

 "How do you shoot the devil in the back?"
 "What if you miss?" -Verbal Kint
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



Sat, 18 Dec 1999 03:00:00 GMT  
 Subject: 64k limit ?????? data segment error ....


Quote:

> >>> You can :

> >>>1) Split the data into different units.

> >> This must me one of the most common false advices in this group. >> It

does not help as the data segment is global.

Quote:

> > Pardon my french, but that us bull.

> Unfortunatly, at least for TURBO and BORLAND Pascal, it is NOT.
> The Memory model choosen by Borland for Pascal allows multiple
> CODE segments, but only 1 global DATA segment.

> Each unit gets it's own CODE segment, but shares a common 64K
> DATA segment.  The only way around it is:

> 1.  Don't over use Global Variables.  They can be dangerous and a
>     waste of resouces.  Declare your variables within the procedures
>     that need them, and pass them as needed.

> 2.  Use Dynamic Memory and Pointers.

> 3.  Dump Borland and DOS and switch to OS/2 and Speed Pascal or
>     Virtual Pascal, for a full 32 bit flat memory model.

You don't have to shout it twice, there's already an echo.

Where can I get Speed Pascal. I heard that it also compiles Windows exes.

--
Vinson ABS.
"30% destiny, 70% hardwork"
"It's not a bug, it's a feature!"



Sat, 18 Dec 1999 03:00:00 GMT  
 
 [ 54 post ]  Go to page: [1] [2] [3] [4]

 Relevant Pages 
 

 
Powered by phpBB® Forum Software