If only one pointer is allocated memory, it is the same as new and dispose. The difference is that getmem can apply for multiple consecutive memory blocks.
Example:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs; Type tform1 = Class (tform) Procedure formcreate (Sender: tobject); end; vaR form1: tform1; implementation {$ R *. DFM} type tmyrec = record {definition structure} Name: String [8]; age: word; end; pmyrec = ^ tmyrec; {definition structure pointer} var PR: pmyrec; procedure tform1.formcreate (Sender: tobject); begin {three structures of memory are allocated at the same time; the three structures in the memory are sequential} getmem (PR, sizeof (tmyrec) * 3); {at this time, PR points to the first structure, with a value assigned to} PR. name: = 'zhang san'; PR. age: = 11; {point PR to the second structure, value assignment} Inc (PR); PR. name: = 'Li si'; PR. age: = 22; {point PR to the third structure, value assignment} Inc (PR); PR. name: = 'wang 5'; PR. age: = 33; {first return to the first structure, and then read} Dec (PR, 2) in sequence; showmessage (format ('% S % d', [pr. name, PR. age]); {Zhang San 11 years old} Inc (PR); showmessage (format ('% S % d', [pr. name, PR. age]); {Li Si 22 years old} Inc (PR); showmessage (format ('% S % d', [pr. name, PR. age]); {Wang Wu 33 years old} {clear the memory of the three structures from the first structure, so that the above three structures are deleted} Dec (PR, 2 ); freemem (PR, sizeof (PR ^) * 3); {sizeof (tmyrec) and sizeof (PR ^) are the same} end; end.
Public Function directory under System Unit