Better buffer handling.

From: George (greerga@DRAGON.HAM.MUOHIO.EDU)
Date: 07/28/97


I'm 90% done with my improved buffer handling system for CircleMUD.
Basically it keeps a list of buffers currently allocated, whether they are
used, how old they are, and how big they are.

If you want a buffer you simply call get_buffer(size) which will return a
pointer to the buffer you received.  When the function is done with it you
call release_buffer(buffer_pointer) and it is returned to service.

To avoid leaks where buffers aren't released, I have a function called
every pulse that checks for unreleased buffers.  It logs which function did
not release the buffer and then releases it.

There is also an option to give buffers a set life expectancy to control
how many buffers are around.  So after 5 minutes of use, the buffer is
removed from service.  If a buffer is requested and one does not exist, it
is created.  There is no maximum amount of buffers since a failed return
would ultimately do more harm.  The release_all_buffers() call makes sure
the buffers are free to prevent a spiral increase.

The buffers are sorted in order of increasing size so 128 comes before
8192.  When one is requested, it traverses the list finding the first
unused buffer that is greater than or equal to the size requested.  If one
is not found, it is created to the exact size as stated above.

I'm currently hunting down functions which don't release their buffers and
then I'll publish the patch to look at.

--
greerga@muohio.edu me@null.net | Genius may have its limitations, but stupidity
http://www.muohio.edu/~greerga | is not thus handicapped. -- Elbert Hubbard


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST