Hi, I have a code, developed in object pascal, with many classes. The project is working fine. Today, I used callgrind (valgrind --tool=calgrind) to see which function consumes the most execution time and I noticed that the most of time in my project is consumed by fillchar function.
Incl. Self. Called Function 29.78 29.72 26M SYSTEM_FILLCHAR$formal$INT64$BYTE 19.07 19.07 123M SYSTEM_MOVE$formal$formal$INT64 3.63 3.63 70M SYSTEM_SYSGETMEM_FIXED$QWORD$$POINTER .... The main caller of FillChar function is system_TObject_$__NewInstance$$TObject which called Fillchar 26 Million times. NewInstance method in TObject calls InitInstance which is an inline function and defined as follows: class function TObject.InitInstance(instance : pointer) : tobject; {$ifdef SYSTEMINLINE} inline; {$ENDIF} begin { the size is saved at offset 0 } fillchar(instance^, InstanceSize, 0); { insert VMT pointer into the new created memory area } { (in class methods self contains the VMT!) } ppointer(instance)^:=pointer(self); if PVmt(self)^.vIntfTable <> @emptyintf then InitInterfacePointers(self,instance); InitInstance:=TObject(Instance); end; My question is do we need to call fillchar in InitInstance? Or Is there any way to avoid calling InitInstance? Amir P.S. I can send you the output of callgrind. _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel