Get available memory (address space) before EOutOfMemory in a Delphi application -
Get available memory (address space) before EOutOfMemory in a Delphi application -
i have 32-bit delphi application running /largeaddressaware flag on. allows allocate 4gb on 64-bit system.
am using threads (in pool) process files each task loads file in memory. when multiple threads running (multiple files beingness loaded), @ point eoutofmemory hits me.
what proper way available address space can check if have plenty memory before processing next file?
something like:
if totalmemoryused {from getmemorymanagerstate} + filesize < "availableuptomaxaddressspace" nooutofmemory
i've tried using
tmemorystatusex.ullavailvirtual availableuptomaxaddressspace
but results not right (sometimes 0, > have).
i don't think can reasonably , robustly expect able predict ahead of time whether or not memory allocations fail. @ to the lowest degree need write own memory allocator dedicated serving application, , have strong understanding of heap allocation requirements of process.
realistically tractable way forwards break free shackles of 32 bit address space. fundamental problem. way escape 32 bit address space compile 64 bit. requires xe2 or later.
you may need go on supporting 32 bit versions of application because have users still on 32 bit systems. modern versions of delphi have 32 bit , 64 bit compilers , quite simple write code compile , behave correctly under both scenarios.
for 32 bit versions less run memory problems anyway because 32 bit systems tend run on older hardware fewer processors. in turn means less demand on memory space because thread pool tends smaller.
if encounter machines big plenty processor counts cause out of memory problems 1 simple , pragmatic approach give user mechanism limit number of threads used application's thread pool.
delphi memory memory-management
Comments
Post a Comment