By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,216 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,216 IT Pros & Developers. It's quick & easy.

some help with Shared Memory

P: n/a
Hi,

Im a Java developer new to PHP development. Im tasked to do some
development playing with Shared Memory (shm http://forums.devshed.com/php-development-5/).
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,
Victor
Oct 14 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
vi************@gmail.com wrote:
If I create a shared memory block of x bytes.

1) How do I check the total that are being *used*.
Please define "use".
2) Can you "resize" a memory block if I get full?
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
Heaven.
-- Mark Twain

Oct 14 '08 #2

P: n/a
"vi************@gmail.com" <vi************@gmail.comwrote:
>
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
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, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 15 '08 #3

P: n/a
On 14 Oct, 02:38, "victor.s.em...@gmail.com"
<victor.s.em...@gmail.comwrote:
Hi,

Im a Java developer new to PHP development. Im tasked to do some
development playing with Shared Memory (shmhttp://forums.devshed.com/php-development-5/).
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,
Victor
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.

C.
Oct 16 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.