473,405 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

some help with Shared Memory

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
3 1769
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Sims | last post by:
Hi, Just like phpBB i have a fairly large language section. For those of you who do not know it there is a global array variable $lang and it contains translations of many word used all over...
5
by: Claudio Grondi | last post by:
Background information: --------------------------------- in order to monitor mainboard sensory data as fan speeds, temperatures, applications like SpeedFan http://www.almico.com/speedfan.php or...
11
by: Michael Schuler | last post by:
The use of STL in shared memory poses a real problem since (non-smart) pointers are not allowed there. Is there any solution for containers in shared memory using smart pointers? Where can I...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
5
by: Ian Bell | last post by:
What is the current thinking on the best way to solve the shared memory problem? Ian -- Ian Bell
8
by: clsmyth | last post by:
Folks, Hi, I have never posted to a language group before so please excuse me if this is inappropriate. I have posted this to comp.unix.solaris (well, I am one of the folks on the thread at...
1
by: Alexander Cohen | last post by:
Hi, sometimes ill get this error: FATAL: could not create shared memory segment: Cannot allocate memory DETAIL: Failed system call was shmget(key=2, size=4153344, 03600). HINT: This error...
9
by: Maxwell2006 | last post by:
Hi, Is there a concept of shared named memory in .NET to allow multiple program use the name and then set/retrieve values? Thank you, Alan
7
by: pike | last post by:
db2 8.1 FP11 on AIX 5.3.0.0 . The db2diag.log is intermittently reporting EMFILE (24) "Too many open files" errors. The culprit is always db2hmon. Sample db2diag.log output follows: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.