Macintosh memory management
Posted in 1992
The external functions that I'm loading require more memory than is available from the stack ( usaully limited to about 2-4 K, with an absolute max of 16k). I'm using MPW C on a Mac IIci with 16M, Wingz ver 1.1, Finder 6.0.5, Multi Finder 6.1b9 There is no relevant documemtaion from Informix regarding this problem other than a nonspecific directive: "..will have to use Mac memory manager." What seems to work is: - save the current zone: Wingz_Zone = GetZone(); - set the zone to the system heap: SetZone(System_Zone()); - get a large chuck of nonrelocatable memory from the system with a call like: zone_base = (Ptr) NewPtr(zone_size); - create a zone from this with a call like: InitZone(NULL,16,(Ptr)(zone_base+zone_size),(Ptr)zone_base); - save the current zone for later use: my_zone = GetZone(); - bracket all calls to malloc(), free() etc with SetZone() calls: SetZone(my_zone); p = malloc(size); SetZone(Wingz_Zone); Although this works better than other tactics, there is at least one problem with this approach: - an unsatisfied call to malloc(), rather that simply returning NULL, will invoke the GrowZone() {used defined, here a NULL fnc ptr} which if it doesn't get more space will hang the system. SO, NOW at last my questions: 1) Is there a better way of doing this under system 6.x 2) Is there a better way of doing this under system 7.x ( Currently Informix's Wingz does not use virtual memory under sys 7; I'm not sure of their plans for release 2.0 due out ???later this year??? ) Thankx much for your help, Larry lar@fsg.com