bryan@geo-works.UUCP (Bryan Ford) (07/22/89)
Is there a way to make AllocMem() call your own routine if it is about to fail? In other words, I'd like to do the same thing as libraries and devices do when memory is low and they're not being used. I know I could patch into AllocMem, but that would create all the problems of SetFunction(), and I really don't want to get into that. I'd rather not mess around with SysBase anyway. I could also add a 'dummy' library to the library list with an Expunge() function that calls my de-allocation routine. I don't really want to do this either, because of the extra library management code it would require. But, unless someone "out there" can give me a better way, this is how I'll do it. Also, if there isn't a better way than this, and nothing to handle this is coming out in 1.4, may I suggest creating a standard library which goes in the LIBS: directory, called, say, "demandfree.library" or something like that. It would maintain a list of routines to call whenever it gets an Expunge() request from the system. It wouldn't be hard at all to create, but could be extremely helpful. Thanks in advance! Bryan P.S. Yes, this *is* necessary in my case. I'm doing lots of caching in chip memory, and I can't keep caches hanging around when somebody else (or another part of my program) needs the memory. -- _______________________________________ _/ Bryan Ford - bryan@geo-works.uucp \_ _/ ..!utah-cs!caeco!i-core!geo-works!bryan \_ / ..!uunet!iconsys!caeco!i-core!geo-works!bryan \ \_____________Author: Chroma Paint______________/
new@udel.EDU (Darren New) (07/27/89)
I kind of remember seeing something in Facc or FaccII that does this. The library gets openned and will send you a message whenever the Expunge routine of the library gets called. I remember that I did not like exactly how it was interfaced, but I think that this part of the code was PD in order to facilitate having everyone use the same library. Sorry -- since I never bought Facc I don't have any more information about it. -- Darren
FelineGrace@cup.portal.com (Dana B Bourgeois) (07/29/89)
The FACC software mentioned is called the ASDG Low Memory Server. It is *not* PD. The software is available for non-commercial use or for commercial use via a license. The terms of the license are: 1. credit is given to ASDG Corp. in a reasonable visible fashion within the documentation. 2. licensee agrees to give ASDG a copy of the finished product. In addition a one time fee of no more than $50 may be required to cover paperwork. I guess it depends on demand whether ASDG will charge for the server. It works by monitoring a lowmemory structure during all waits. This structure is created by your program. You also need a LMS message port. You create the structure and port. You register the port with the server. You set the lm_flag to lm_condition_ackknowledged and reset it after every message from the LMS. You don't reply the message received. The reason for this non-standard way of sending messages is that the LMS is assumed to be working while RAM is in short supply and allocating a message structure and replying the message may not work due to the RAM shortage. The message structure is therefore created ahead of time and only flags are checked. When exiting, you de-register with the LMS, then close the LMS library. All the above came from the LMS docs. Send me email and I will mail this stuff to you (if possible from Portal). I used to use the LMS option with FaccII but about half the time I got crashes when memory got tight(I opened emacs until the server went into action). Without LMS the system thrashes but doesn't crash (well hardly ever if you are careful and close something fairly big) so I stopped using it. Now with expansion RAM it is a moot point for me. Dana The above opinions in no way reflect the opinions of my employer. Why should they? They don't know I babble on UseNet.