On Mar 16, 2005 at 17:08, szj <zjsun(a)biigroup.com> wrote:
When I browse the ser code, I found there are three kind of memory
allocation.The most frequently used is shm_malloc() and pkg_malloc().
the first have lock functions and the latter is not. I found that
the transaction struct cell and its field is allocated with shm_alloc,
but others are allocated with pkg_alloc(). I added a pointer member
into the cell struct. If I allocate a block of memory for my pointer
member with pkg_malloc(), the ser will crash when some one want to
establish a call through ser. If using shm_malloc(),all will go well.
What I want to know is when and where I should use shm_malloc() and
pkg_malloc().
shm_malloc will alloc shared memory, that will be visible from other ser
processes.
pkg_malloc will use "private", per process memory (it will not be
visible from other ser processes).
pkg_malloc is much faster (because it doesn't need locking).
If you need to alloc. something temporarily, or something that doesn't
need to be seen from another process use pkg_malloc.
Andrei