JCL Help:SizeOfMem

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Returns the size of a memory block given a pointer.


Pascal

 function SizeOfMem(const APointer: Pointer): Integer;


Parameters

Parameters Description
P Pointer to the memory block whose size to retrieve.


Return Value

The total size of the memory block pointed to by P. Note that the current implementation uses a 4 byte header to store some additonal information (such as the size) about the memory block. These 4 bytes are included in the result. To get the size of the block available to the user (the size specified when the block was allocated) simply subtract 4. If the function fails to determine the size of the memory, for example because it detected that the Delphi memory manager was replaced by a custom memory manager, it returns -1.


Description

SizeOfMem returns the size of the memory block pointed to by the specified pointer. This routine depends on information peeked from the standard Delphi memory manager implemention (in GetMem.inc) and will not work when a custom memory manager replacement is in use. Also, it will only work for memory allocated using the AllocMem, GetMem and New routines; that is, using the Delphi memory manager.


About

Unit

JclSysUtils


Donator

Robert R. Marsh


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page