Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!ukc!reading!minster!alistair From: alistair@minster.york.ac.uk Newsgroups: comp.sys.mac.programmer Subject: Object Pascal and memory management Message-ID: <604330910.18716@minster.york.ac.uk> Date: 24 Feb 89 13:41:50 GMT Organization: Department of Computer Science, University of York, England Lines: 38 Can anyone out there explain how Object Pascal objects are allocated in memory, and the relationship to segementation? I have a program which sometimes bombs due, I suspect to memory problems. I should say that I am NOT using MacApp. An object is a handle, right. So when if write: type Tthing = object(Tobject) i : integer; procedure p; ... end; {$S seg1} procedure Tthing.p; ... {$S seg2} var thing : Tthing; begin new(thing) New allocates some memory on the heap and thing is set as an indirect pointer to it. What goes in that bit of memory: the code for Tthing (i.e. for Tthing.p) and/or space for the instance variable i? What if I call new for another Tthing object? Surely I don't need another copy of the code for Tthing.p, but do I get one anyway? What does dispose(thing) do? And then... I have had to segment my program because the compiler began to complain about segments >32K, but what does that mean in the context of objects? Can I unload a segment I have finished with by something like UnloadSeg(@thing.p) - and what would it mean if I did? How would that work in relation to a dispose(thing)? I hope someone out there is able and willing to help. I did try getting the answers from the Apple Developers' Group - the British version of APDA - and they knew no more than me, and couldn't be bothered finding out. As far as I'm concerned they are a waste of time and I don't care who knows it. (These are - of course - NOT necessarily the views of my employers, blah blah blah)