Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!rbbb.Eng.Sun.COM!chased From: chased@rbbb.Eng.Sun.COM (David Chase) Newsgroups: comp.lang.modula3 Subject: Re: Allocation of objects in other than default heap ? Message-ID: <7957@exodus.Eng.Sun.COM> Date: 13 Feb 91 21:38:46 GMT References: <9102131620.AA13112@riposte> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 41 In article <9102131620.AA13112@riposte> saber.com!wyant@saber.com writes: >... Suppose I want some objects to be allocated from the process >private heap, but some I want allocated out of a heap existing in >shared memory (for instance I might be writing a fast local IPC >mechanism). I don't see any way in M3 of specifying which heap should >be used for a given allocation. Is there in fact a recommended way of >doing this ? I recommend you write an UNSAFE implementation for a SAFE interface (if you can guarantee that it is truly safe). You certainly shouldn't expect to allocate TRACED objects from such a pool (especially for your example), since doing so assumes a certain amount of clairvoyance on the part of the author of the memory allocator and garbage collector. If you decide to allocate UNTRACED OBJECTS from that heap, you'll need to get into bed with the compiler/run-time's representation of TYPECODEs and method suites. This is distinctly non-portable, but so it goes. I realize that this is probably not the helpful answer that you wanted, but programing in unsafe/untraced M-3 is no worse than programming in C, except that it is more verbose. I can see where you might wish for something like C++'s new-at-specified-location; perhaps that should be considered. However, be aware of the following problems with such a scheme: (1) you need an interface that provides the size for the object and for its hidden data structures (2) ynaitp the align for the object etc (3) ynaitp the offset of the user-visible pointer from the actual beginning of the allocated memory for the object. People who are paid to think about these things can no doubt find other problems, and I wouldn't mind hearing about them. For UNSAFE code, it might be handy to be able get this function from a some sort of optional standard interface. Any thoughts from the committee on this? It seems like such an interface could be based on typecodes. (Is this already in 1.6, which I haven't bothered to fetch yet? I'll go look, in my copious free time.) David Chase Sun