some help with Shared Memory

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


     Im a Java developer new to PHP development.  Im tasked to do some
development playing with Shared Memory (shm /).
Im a little curious about the consequences that are a little unclear
in the documentation.

     If I create a shared memory block of x bytes.

     1)  How do I check the total that are being *used*.  With
shm_size I can find out the shared memory size but not the size that
are used in that block.  I need a mechanism to determine whether Im
close to a certain high water mark of the memory block

     2)  Can you "resize" a memory block if I get full?  Or do I have
to make a new block, copy everything over ala ArrayList in Java?

Thanks for your help,

Re: some help with Shared Memory wrote:

Quoted text here. Click to load it

Please define "use".

Quoted text here. Click to load it

Please refer to a POSIX C programming manual for a full reference on how to
work with shared memory blocks. PHP doesn't reimplement anything, it just
calls most of the POSIX C interface as transparently as possible.

Anyway, general tips: When you're working with shared mem, you're supposed
to know what your doing. You're supposed to know how C memory management
works. Do not rely on Java (or any other high-level language) assumptions
on how the memory system works.

Iván Sánchez Ortega -ivan-algarroba-sanchezortega-punto-es-

The secret source of humor is not joy but sorrow; there is no humor in
                -- Mark Twain

Re: some help with Shared Memory

Quoted text here. Click to load it

As soon as you create a shared memory block of X bytes, as far as the
operating system is concerned, all X bytes are "used".  It is entirely up
to you to decide what to do with that memory.  If you are storing things in
that block, then it's up to you to track the usage.

The operating system will not allocate memory out of your shared block.
It's up to you.
Tim Roberts,
Providenza & Boekelheide, Inc.

Re: some help with Shared Memory

On 14 Oct, 02:38, ""
Quoted text here. Click to load it

As others have pointed out - its all well documented.

But I suspect you may be using shm because you're still designing your
programs as if they were Java programs running in threads. Although
there are uses for shm with PHP, they are somewhat niche. You may want
to take a long hard look at whether shm is the right PHP way to solve
your current problem.


Site Timeline