Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: more than 64k global variable


This question is answered.


Permlink Replies: 3 - Last Post: Oct 2, 2017 5:39 AM Last Post By: david chesnet Threads: [ Previous | Next ]
david chesnet

Posts: 2
Registered: 10/4/00
more than 64k global variable  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2017 10:09 AM
Hello,
I'd like to understand something that seems strange in the following code snippet declarations.
If my count is right, the record is 4 integers = 4*4 bytes in a 6000 samples array , it is then 16*6000 = 96kb heavy.
My array is static and defined as a global variable (unit interface). It excesses the 64k limit of the data segment where global variable are stored. I should have run out of memory, but it works perfectly.
How is it possible ? (runs with D2007 under Windows7 32bits).
Is the array located on the heap, and only the variable to access is stored in DS ?
If any has light to shed on this mystery, I'd be glad to understand subtileties of Delphi memory managment !
David

UNIT TabDefs;
INTERFACE

USES
Windows, SysUtils, Classes, StdCtrls;

TYPE
ADD2 = packed record
Pressure,
XP, YP,
MsTime : integer;
end;

CONST
MaxAdd = 6000;
VAR
TabBuffer : array[0..MaxADD-1] of ADD2;
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: more than 64k global variable
Correct
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 28, 2017 10:22 AM   in response to: david chesnet in response to: david chesnet
david chesnet wrote:

It excesses the 64k limit of the data segment where global variable
are stored.

That only applies to 16-bit systems, not to 32/64-bit systems.

Is the array located on the heap, and only the variable to access is
stored in DS ?

No.

--
Remy Lebeau (TeamB)
david chesnet

Posts: 2
Registered: 10/4/00
Re: more than 64k global variable  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 2, 2017 5:39 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:
david chesnet wrote:

It excesses the 64k limit of the data segment where global variable
are stored.

That only applies to 16-bit systems, not to 32/64-bit systems.

Is the array located on the heap, and only the variable to access is
stored in DS ?

No.

--
Remy Lebeau (TeamB)
Wow, documentation I found is as old as me ;-)
Thanks a lot for the update !
David
Jacinto Franca

Posts: 10
Registered: 10/15/00
Re: more than 64k global variable
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Oct 2, 2017 2:18 AM   in response to: david chesnet in response to: david chesnet
El 9/28/2017 6:09 PM, david chesnet escribió:
Hello,
I'd like to understand something that seems strange in the following code snippet declarations.
If my count is right, the record is 4 integers = 4*4 bytes in a 6000 samples array , it is then 16*6000 = 96kb heavy.
My array is static and defined as a global variable (unit interface). It excesses the 64k limit of the data segment where global variable are stored. I should have run out of memory, but it works perfectly.
How is it possible ? (runs with D2007 under Windows7 32bits).

The 64k limit is for 16 bits (Delphi 1). For 32 bits the limit is 4 GB.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02