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

Delphi problems: memory and data segment constraints ?

blems with Delphi:

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

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?

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

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"


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?

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$>, (Aarthi  Natarajan) wrote:


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.



Other Threads