diff --git a/rtl/inc/heaptrc.pp b/rtl/inc/heaptrc.pp index f7c6d7ce47..73192a68f8 100644 --- a/rtl/inc/heaptrc.pp +++ b/rtl/inc/heaptrc.pp @@ -371,7 +371,14 @@ begin {$endif cpuarm} if add_tail then inc(allocsize,sizeof(ptrint)); + { if ReturnNilIfGrowHeapFails is true + SysGetMem can return nil } p:=SysGetMem(allocsize); + if (p=nil) then + begin + TraceGetMem:=nil; + exit; + end; pp:=pheap_mem_info(p); inc(p,sizeof(theap_mem_info)); { Create the info block }