Sitemap | Search || Zen Spider Website
/ Satori
/ Satori Class Index
/ Class Memory
Class Memory
Description:
This is a garbage collector/memory manager. It
provides an invisible means, through GCable, to allocate
objects in a dynamic garbage collected heap.
Public Methods:
-
Memory
(UInteger size = UInteger(524288L);
-
I am the constructor I default the size to 512Kb. I also
initialize myPools, myBottom, and myTop.
-
~Memory
();
-
I am the destructor for class memory. I delete myPools and set
myPools, myBottom, myTop, and myMemory to NULL.
-
static GCable *
allocate
(size_t size);
-
I am the public accessor to real buddha's allocate(). If I can't
initially allocate bytes, then I call collect and try again.
-
static void
free
(GCable *);
-
Currently I am a null method and will be used for later growth...
-
Boolean
collect
();
-
Duh, I start collecting... You don't need to call me as I get
automatically called when an allocation initially fails.
-
static void
remember
(GCable ** root);
-
I add root to the list of known roots. Roots are the external
pointers that point to a GCable object within my memory.
-
static void
forget
(GCable ** root);
-
I remove root from the list of known roots.
-
static Memory &
buddha
();
-
I am the accessor/initializer to buddha. Use me to do things.
//////////////////////////////////////////////////////////////////////////////
services for buddha's followers
//////////////////////////////////////////////////////////////////////////////
Protected Methods:
-
void
preStatistics
();
-
-
void
postStatistics
();
-
-
GCable *
reincarnate
(GCable * ptr, UInteger size);
-
I am responsible for copying an object referenced by ptr to
a new instance of itself. I know how much to copy by the size
parameter... This allows for any length objects to be collected.
-
void
swap
();
-
I swap from one pool to another. I don't do too much, and I am
called directly from collect(), so don't call me... You'll mess
something up...
-
Boolean
validate
(GCable * ptr);
-
I verify that a pointer is OK to mess with and return true if
it is OK, false otherwise. Basically if the pointer is non-null
and points within either of my two pools, it is OK.
//////////////////////////////////////////////////////////////////////////////
services private to buddha
//////////////////////////////////////////////////////////////////////////////
-
GCable *
create
(UInteger size);
-
I do all the work for allocate, which means I actually create
and account for space for any given object...
-
UInteger
resize
(UInteger size);
-
I calculate the proper boundry size for a memory block. I make
sure that the memory that you allocate is a proper size, namely,
some multiple of the size of a generic pointer.
-
char *
top
();
-
I return a pointer to the top of the current pool.
-
char *
memory
();
-
I return a pointer to the next available location in the current
pool. Treat me like a new pointer...
-
char *
bottom
();
-
I return a pointer to the bottom of the current pool.
//////////////////////////////////////////////////////////////////////////////
data private to buddha
//////////////////////////////////////////////////////////////////////////////
Protected Members:
-
friend class
GCable;
-
-
UInteger
myTime;
-
Number of seconds to collect
-
UInteger
myTotalCollections;
-
Number of objects reincarnated
-
UInteger
myTotalAllocations;
-
Number of objects created (incl. collections)
-
UInteger
myPoolSize;
-
I am the size of both pools, in bytes.
-
char *
myPools[2];
-
I am pools #0, and #1.
-
char *
myBottom;
-
I am the pointer to the bottom of the current pool.
-
char *
myMemory;
-
I am the pointer to the next available location in the current
pool.
-
char *
myTop;
-
I am the pointer to the top of the current pool.
I was getting sick of having to compile list code everywhere...
-
List<GCable **>
myRoots;
-
I am a list of "root" pointers - pointers that are outside of the
pools, but point in...
//////////////////////////////////////////////////////////////////////////////
static members of buddha
//////////////////////////////////////////////////////////////////////////////
-
static Memory
theBuddha;
-
I am the buddha... There is buddha nature in all.
Sitemap | Search || Zen Spider Website
/ Satori
/ Satori Class Index
/ Class Memory