Thanks, Richard. I actually arrived at that by experimenting, but I had no idea whether I was doing it right. Thanks for the explanation - it confirms that I've got it set up correctly.

Kind regards,

Philip Bennefall

On 9/5/2016 12:13 PM, Richard Hipp wrote:
On 9/5/16, Philip Bennefall <phi...@blastbay.com> wrote:
Hi all,

First, if this is the wrong place to ask this question, please let me
know and I will ask elsewhere.

I have a question about memsys5, which I am using as a general purpose
memory pool in my application. I am allocating fixed size objects, and I
have set mReq to the size of that object (it is a power of 2). I know
that I will only be using N objects at any given time. Is there an easy
way to calculate how much space I need to reserve in order to hold N
objects simultaneously? If I allocate a total of N*sizeof(object) bytes,
it doesn't seem to let me store N objects at the same time. Am I doing
something wrong or is this expected?

Let sz be the number of bytes of memory you provide to the memory
allocator.  The number of minimum-size objects that can be stored is
sz/(mnReq+1).  Not sz/mnReq.  The extra +1 is some space taken from
the front of the provided memory and used for internal bookkeeping.

--
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to