On Thursday 20 March 2003 09:27, you wrote: > >> > Hi again - > >> > > >> > another question; what is the best way to "fail" a constructor call? > >> > >> For > >> > >> > example, I have a constructor "timage.loadimage()", and I want it to > >> > return > >> > "nil" if it encounters a problem (e.g. the file name doesn't exist). > >> > >> My > >> > >> Use fail :-) > > > > But, when I use fail in my simple example program, it returns NIL okay > > but the Heaptrace function tells me I have two unfreed memory blocks (36 > > bytes). > > I can't see a memory leak anywhere else in that program, what could cause > > this? (Heaptrace output is as follows: I am using FPC 1.0.6 btw) > > > > Heap dump by heaptrc unit > > 13 memory blocks allocated : 224/248 > > 11 memory blocks freed : 188/208 > > 2 unfreed memory blocks : 36 > > True heap size : 20000000 (64 used in System startup) > > True free heap : 19999792 > > Should be : 19999800 > > Call trace for block 0x0040AEA4 size 24 > > 0x004051AF > > 0x00401ECC MYTESTCLASS__CREATE, line 13 of > > e:/projects/tests/classtst.pp > > 0x00401DC6 main, line 26 of e:/projects/tests/classtst.pp > > 0x00401059 > > Call trace for block 0x0040AEF4 size 12 > > 0x00405176 > > 0x00401ECC MYTESTCLASS__CREATE, line 13 of > > e:/projects/tests/classtst.pp > > 0x00401DC6 main, line 26 of e:/projects/tests/classtst.pp > > 0x00401059 > > That is the exception frame that is left on the heap. I don't have the > time to analyze what the cause is that the exception frame is not removed. > > > > _______________________________________________ > fpc-pascal maillist - [EMAIL PROTECTED] > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Maybe off-topic, but I thought about a constant static object at address 0 or so, in order to have the program stilll working when a constructor returns NIL (which has value 0). Would that be possible, e. g. under GNU-Linux? anton tichawa. ---------- "Adas Methode war, wie sich zeigen wird, Tagträume in offenbar korrekte Berechnungen einzuweben." Doris Langley Moore: Ada, Countess of Lovelace (London 1977). ---------- Anton Tichawa Volkertstrasse 19 / 20 A-1020 Wien mobil: +43 664 52 07 907 email: [EMAIL PROTECTED] ---------- _______________________________________________ fpc-pascal maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-pascal