From b889b42a8c9f8b9e74007cb799b61aa8f93177ee Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 4 Oct 1999 09:48:57 +0000 Subject: [PATCH] Tidied git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4967 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 4 ++ Documentation/gnustep-base.tmpl.texi | 67 +++++++++++++++++++++++++++- Tools/gdomap.c | 7 ++- Tools/gdomap.h | 2 +- 4 files changed, 74 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 86e633303..b004e98e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Mon Sep 4 11:06:00 1999 Richard Frith-Macdonald + + * Tools/gdomap.c: better debug output (hopefully) + Wed Sep 29 21:34:00 1999 Richard Frith-Macdonald * Source/NSData.m: More GC updates (atomic data buffer) diff --git a/Documentation/gnustep-base.tmpl.texi b/Documentation/gnustep-base.tmpl.texi index 253ef798d..2065c10aa 100644 --- a/Documentation/gnustep-base.tmpl.texi +++ b/Documentation/gnustep-base.tmpl.texi @@ -152,10 +152,75 @@ Type @code{make install} to install the libraries and programs @chapter Implementation Details @menu +* Memory Management:: * Time Zone:: @end menu -@node Time Zone, , Implementation, Implementation +@node Memory Management, Time Zones, Implementation, Implementation +@section Memory Management + +The OpenStep standard defines an reference-count based memory management scheme which the GNUstep libraries support. GNUstep also supports garbage collection +using the Boehm conservative garbage collecting library, though this is +currently (October 1999) in a pre-alpha state. + +@menu +* Memory Allocation:: +* Reference Counting:: +* Garbage Collection:: +@end menu + +@node Memory Allocation, , Reference Counting, Memory Management +@section Memory Allocation + +Normally, memory is allocated in zones. Most memory is allocated from a +default area (returned by the NSDefaultMallocZone()) function. In some cases +where you want to ensure that a group of objects are all located in roughly the +same area of memory (for performance reasons) you might create a special zone +and allocate the objects fromn that area. + +At a low-level, memory allocation is performed by two functions - +NSAllocateObject() and NSDeallocateObject(), but you need never normally deal +with these functions - they are there for when you need an unusual degree of +control or performance. These are the functions called by +[NSObject +allocWithZone:] and [NSObject -dealloc]. If you call +NSAllocateObject() directly to create an instance of a class, you may break +some functionality of that class (such as caching of frequently used objects). + +Generally, objects are created using the methods +alloc, -copy, -mutableCopy +and are destroyed using -dealloc. The allocation methods are covers for the +more versatile +allocWithZone:, -copyWithZone: and -mutableCopyWithZone: +methods. NSObject also provides +new, which is simply a cover for the +combination of a +alloc and a -init. + +@node Reference Counting, Memory Allocation, Garbage Collection, Memory Management +@section Reference Counting + +The reference counting scheme for object allocation/deallocation is quite +simple. Objects are normally created with a reference count of 1. An objects +reference count may be increased by callsing -retain, and decreased by calling +-release. If a -releae would make the reference count become zero, the +-dealloc method is automatically called to destroy the object - freeing its +memory. + +This simple scheme then becomes more complicated with the addition of +the -autorelease method. When -autorelease is called for an object, the +object is added to the currently active autorelease pool. When the autorelease +pool is later destroyed, every object in the pool will have a -release message +sent to it for each time it was added to the pool. Thus, sending an +-autorelease method to an object is equivalent to sending a -release at some +future point. + +In general, when a method (other than the alloc..., copy..., mutableCopy... +and new... methods) returns an object, that object will have been autoreleased, +so you don't need to worry about releasing it yourself. However, if you wish +to store the object for any length of time, you will need to send it a retain +message, and then send it a release when you have finished with it. + +@node Garbage Collection, Reference Counting, Memory Management, Memory Management +@section Garbage Collection + + +@node Time Zone, , Memory Management, Implementation @section Time Zones If the GNUstep time zone datafiles become too out of date, one can diff --git a/Tools/gdomap.c b/Tools/gdomap.c index 2dfc7c605..4530460ab 100644 --- a/Tools/gdomap.c +++ b/Tools/gdomap.c @@ -3156,16 +3156,15 @@ printf( * Ensure we don't have any open file descriptors which may refer * to sockets bound to ports we may try to use. * - * Use '/dev/tty' to produce logging output and use '/dev/null' - * for stdin and stdout. + * Use '/dev/null' for stdin and stdout. Assume stderr is ok. */ for (c = 0; c < FD_SETSIZE; c++) { - (void)close(c); + if (c != 2) + (void)close(c); } (void)open("/dev/null", O_RDONLY); /* Stdin. */ (void)open("/dev/null", O_WRONLY); /* Stdout. */ - (void)open("/dev/tty", O_WRONLY); /* Stderr. */ init_my_port(); /* Determine port to listen on. */ if (interfaces == 0) diff --git a/Tools/gdomap.h b/Tools/gdomap.h index bb9450279..794b0fbb9 100644 --- a/Tools/gdomap.h +++ b/Tools/gdomap.h @@ -209,7 +209,7 @@ typedef struct { #define GDO_REQ_SIZE sizeof(gdo_req) /* Size of a request packet. */ /* - * If you have a fascist sysadmin who wqill not let you run gdomap + * If you have a fascist sysadmin who will not let you run gdomap * as root and will not even let you modify /etc/services to point * gdomap to another port, you can uncomment the next #define to * run gdomap on port 6006 (or modify this to a port of your choice).