home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / amiga / programm / 18255 < prev    next >
Encoding:
Text File  |  1993-01-07  |  2.7 KB  |  76 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: sparky!uunet!munnari.oz.au!penguin!gduncan
  3. From: gduncan@philips.oz.au (Gary Duncan)
  4. Message-ID: <1993Jan7.092127.13752@philips.oz.au>
  5. Date: Thu, 7 Jan 93 09:21:27 GMT
  6. Organization: Philips Public Telecommunications Systems, Melbourne, Australia
  7. Subject: Flushing Devices;  C= doco (mutter!)
  8. Lines: 66
  9.  
  10. Ever done an "RTFM" on a key issue, can't find the answer, asked for 
  11. help then later find it was in "TFM" but so described as to be easily
  12. overlooked but allow the manual writers to say "well its in there" ?
  13.  
  14. Yes ? Causes some stress doesn't it ? Definitely generates negative
  15. thoughts. Anyway...
  16.    
  17. A few days ago I posed a question on how to flush unused
  18. devices out of RAM from a program (as distinct from doing it from the 
  19. command line using "Avail Flush", for example). Nothing in the
  20. RKMs seemed to answer this question (but read on).
  21.  
  22. In my case getting rid of the serial device was the issue. Having it hang 
  23. around unused after my program exitted gave a false impression of a 
  24. memory leak. 
  25.  
  26. Well I got some helpful replies on how to force a flush from
  27. requesting  gigabytes (thus causing Exec to flush unused libraries
  28. and devices from RAM) to suggestions of  using the Flush entry in
  29. a device. Fortunately someone had made a passing reference to some
  30. code examples so I managed to trip over one of C='s 1.3 examples
  31. (dated May 1990) issued on Fish Disks and saw a neat example on
  32. how to do it (para-coded below).
  33.  
  34. Armed with this info I rescanned the RKM-Libraries (ed 3) index
  35. and noticed a "FlushDevices()" entry {my brain had been previously
  36. programmed to look for keywords like Remove/Delete/Expunge and in
  37. big bold letters, not as a side issue to a specific chapter}. 
  38. This lead to a discussion/code as shown below and in fact answered my query.
  39.  
  40. So what I'm saying is that there is a real deficiency in that 
  41. manual to do with this issue. There should at least have been
  42. a reference to RemDevice() which would have lead on one.
  43.  
  44. I feel better now :)
  45.  
  46. Passing thought ; why the heck aren't unused libraries/devices
  47. flushed automatically anyway? Sounds like a legacy of the days 
  48. when hard disks were rare and dragging a device off floppy was
  49. time-consuming. Those days are gone...
  50.  
  51.  
  52. - Gary  
  53.  
  54.  
  55. --------------------------------------------------------------
  56. extern struct ExecBase *SysBase;
  57.  
  58. void
  59. FlushSerDevice (void)
  60.  
  61. {
  62.   DEVICE *dev;
  63.  
  64.   Forbid ();
  65.   if (dev = (DEVICE *) FindName (&SysBase->DeviceList, SERIALNAME))
  66.     RemDevice (dev);
  67.  
  68.   Permit ();
  69. }
  70.  
  71. -- 
  72. -----------------------------------------------------------------
  73. Gary Duncan            gduncan@rosella.pts.philips.oz.au    
  74. Philips Public Telecommunications Systems    Phone: +61 3 8813666
  75. Melbourne, Australia                     Fax: +61 3 8813577
  76.