Board index » delphi » Delphi problems: memory and data segment constraints ?

Delphi problems: memory and data segment constraints ?

blems with Delphi:

1.
Allocation of Memory greater than 64K.
What is the difference between GlobalAlloc and Global32Alloc?

2.
I allocated memory greater than 64K using GlobalAlloc and copy a
whole data segment into this memory.  But when I tried to access
the data in the address beyond 64K, I get run-time errors.
(*I guess it is illegal pointer access*)
So, how to access the memory allocated using GlobalAlloc beyond 64K?

3.
Use of Global32Alloc for allocation of huge memory blocks, requires
the support of a unit "WINMEM32".  But when I include unit
WINMEM32 in the "uses" part of Delphi, it reports an error
"Cannot find WINMEM32.dll".

4.
From the online Delphi Help, I discovered that there are special WIN API
I/O routines for reading and writing large data segments, that are greater
than 64K such as _hread and _hwrite.   But, these I/O routines require a
unit namely "WIN31" as indicated by Delphi Help.  However, when I
included "WIN31" in the "uses" part of Delphi, Delphi reports an error
 "Cannot findWIN31.dcu"

5.
PathName:PChar;
Handle1,maximum,handle2:Integer;
Newbmph:BitmapFileHead;
Headsize,Datasize,NumBytes:Longint;
Out1,Out2:arraytype;
x1,x2,y1,y2:arraytype;

For the above declaration of local variables, I obtain a run-time error.  
The problem is that the data segment allocated for the local variables exceed
the maximum limit of {stack-size + heap-size = 65536 bytes}.  
How do I increase the memory model to handle more than65536 bytes.

6. Will these memory allocation problems be encountered in Windows 95? Does
Windows 95 have similar data segment constraints?

7.
My last question, which summarises the above problems:
How to allocate large segments of memory ( >64K )?
How to read and write to these huge segments?
How to access the data stored in this memory?  
How to increase stack-size to more than 65536 bytes (for declaration of
local variables ?)

 

Re:Delphi problems: memory and data segment constraints ?


In article <4236ad$...@mirv.unsw.edu.au>,
   aar...@cse.unsw.edu.au (Aarthi  Natarajan) wrote:

Aarthi

Most of the problems you identify are in-principle difficulties that arise
from Windows architecture. The 32 bit version of Delphi will make accessing
huge memory blocks much easier.

However, you can use the _hread and _hwrite functions within Delphi (using
GlobalAlloc). The documentation doesn't mention it, but the FileRead and
FileWrite functions in the SysUtils unit are aliases for these two functions.
You'll find them documented in online help.

HTH

Ian
i...@dircon.co.uk

Other Threads