From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f6ee8ca03c176d76 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-30 01:10:12 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!news.teledanmark.no!uninett.no!dax.net!juliett.dax.net!not-for-mail Newsgroups: comp.lang.ada Subject: Re: stupid question: how can I finish a program? References: <5ee5b646.0208241822.34540e8b@posting.google.com> <3D6D00B9.60EECCFB@san.rr.com> <3D6D4F44.4872BCFA@san.rr.com> <3D6E507E.7010805@cogeco.ca> From: Ole-Hjalmar Kristensen Message-ID: <7vadn4bwe3.fsf@vlinux.voxelvision.no> User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Fri, 30 Aug 2002 08:09:40 GMT NNTP-Posting-Host: 193.216.12.150 X-Complaints-To: abuse@tele2.no X-Trace: juliett.dax.net 1030694980 193.216.12.150 (Fri, 30 Aug 2002 10:09:40 MET DST) NNTP-Posting-Date: Fri, 30 Aug 2002 10:09:40 MET DST Organization: Tele2 Norway AS Public Access Xref: archiver1.google.com comp.lang.ada:28586 Date: 2002-08-30T08:09:40+00:00 List-Id: "Warren W. Gay VE3WWG" writes: > Robert A Duff wrote: > > Darren New writes: > >>Robert A Duff wrote: > >>>Darren New writes: > >>>>Robert A Duff wrote: > >>>> > >>>>>If you're running under a proper operating system, then all resources > >>>>>visible outside the program will be cleaned up when the program exits. > >>>> > >>>>This is true only in the most trivial sense. If I have a program that > >>>>contacts a license manager (for example) and grabs the license, then aborts, > >>>>I could be in trouble. That's why license managers check for that sort of > >>>>failure. > >>> > >>>So if it's checked for, what's the problem? > >> > >>Well, it isn't the OS doing it. > > OK, I admit, I was oversimplifying. > > Still, if the OS allocates some physical memory to a process, and the > > process dies, the OS ought to reclaim that memory. If a license manager > > allocates a license to a process, and the process dies, the license > > manager ought to reclaim it. ... > > Even in "proper O/S" there are occaisions where cleanup is needed, > but not automatically done by the O/S. Here are 3 examples of > this, that can happen on [pick your] UNIX: > > - Allocated _SHARED_ memory > - Created message queues (IPC) > - Create semaphores > > The reason these are not automatically cleaned up by the O/S is that > sometimes you want them to persist beyond the creating process' > lifetime (because they are shared by other processes). > Certainly, it can cause a leak, but the leak does not get bigger when you run the program again, because as you point out, you can aquire the same resource again, and it's pretty trivial to check for the existence of those *named* objects on startup. Contrast this with an OS which leaks memory, does not close file handles, etc. On the next run of the program, you will probably aquire a *new* chunk of memory or another file handle, and so the garbage will build up over time.