473,746 Members | 2,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shared Memory Limit?

I'm using PHP 4.2.2 on RH9 Linux (with Progeny.com updates, in case
you're wondering). I was using shared memory (shm* API) a great deal
in my web applications because I have 1GB of RAM on this system. By
using shared memory, I can optimize web pages a little by not having
to hit the database every time I want to regurgitate a somewhat-static
reference table.

You may be familiar with the API that looks like this:

$key = 'My Key';
$value = 'My Value';
$app = 'lovelyapp'; //lovelyapp would be the fake name of my web app
$key = $key . '1.5'; //1.5 was the version of my web app, to provide
uniqueness
$segment_key = abs(crc32($app . $key));
$segment_size = 1024;
$segment_perms = 0600;
$shm_id = shm_attach($seg ment_key, $segment_size, $segment_perms) ;
shm_put_var($sh m_id, $app . $key, $value);
shm_detach($shm _id);

This was working rather beautifully for me until I started messing
with the '1.5' literal. The reason, I suspect, was that I had been
using the app (without a bounce of httpd or entire server) and storing
stuff in shared memory with keys of 1.3, 1.4, 1.5, and 1.51 as my app
went through various revisions. This allowed different versions of the
app to simultaneously exist on the same web server and have an
exclusive section of shared memory.

I didn't think I was storing a tremendous amount of stuff there --
perhaps no more than 1MB per shared memory section (determined by
$segment_key).

Finally, *KABOOM* my web app died with the error "Not enough space on
device" and pointed out the error was on the line where I used
shm_attach().

So, I thought -- no problem -- no one using the app this late, so I'll
just bounce the web server (httpd). I did and the error still occured.
I thought, okay, clear my local browser cache and try again. Nope --
still occurred. I tried to bounce httpd again and even go straight to
the web server itself and see if a web page would have the same error.
Yep -- it had the same error no matter what I did.

I had no choice but TO REBOOT THE ENTIRE LINUX WEB SERVER. This
definitely cleared up the problem and I've now hammered on that server
for awhile now with the web app and all looks well.

What's your diagnosis? And, why didn't bouncing httpd clear it up
since Apache spawns PHP as a child process and PHP spawns shared
memory as a child process -- at least I thought it did?
Jul 17 '05 #1
1 3890
Hello,

On 07/22/2004 10:58 PM, Google Mike wrote:
What's your diagnosis? And, why didn't bouncing httpd clear it up
since Apache spawns PHP as a child process and PHP spawns shared
memory as a child process -- at least I thought it did?


Sometimes when an Apache process dies the shared memory it allocated is
not removed. It is like a file. In Linux, just ipcs and ipcrm commands
to list and remove lost shared memory blocks.

BTW, using shared memory for that caching purposes may lead to that
problem if you have to many blocks to cache. It is probably better to
use file based caching as usually there is much more space available and
is easier to garbage collect.

For generic content I use this file based cache class:

http://www.phpclasses.org/filecache
--

Regards,
Manuel Lemos

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/

Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2623
by: Kenton Smith | last post by:
I am using a shared server and the max PHP memory limit is set at 10MB. I can not change this. I would like to resize uploaded JPG images. I have tried many different scripts using the GD libs, but they all do not work for larger JPGs. I know that the limit is the max PHP memory, but is there anything that I can do to get this to work? ImageMagick? Java? Thanks
0
4408
by: Srijit Kumar Bhadra | last post by:
Hello, Here is some sample code with pywin32 build 203 and ctypes 0.9.6. Best regards, /Srijit File: SharedMemCreate_Mutex_win32all.py # This application should be used with SharedMemAccess_Mutex_ctypes.py or SharedMemAccess_Mutex_win32all.py
11
4902
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 find templates?
3
2470
by: Rich | last post by:
Hello all I have an application that is segmented into various Dlls, one of which contains caching mechanisms that create very large in-memory data structures. No matter what I do to attempt to allow the Application to utilize 2-3GB of RAM, both through standard and /3GB /4GT /PAE switches and the like for the system and combinations of /LARGEADDRESS... etc. for the app config .. the App will always fail when it hits *1GB* on the
14
5126
by: Ember | last post by:
Does anyone have documentation on the limit for database shared memory on Red Hat AS 2.1? On AIX, I know it's 2 GB minus the segments allocated for db2 core functionality (so about 1.7), but I need the numbers for Linux (I've heard that it's only 1 GB). I would also really love it if anyone knows where this is officially documented so I can point some of the teams I'm working with to it. Thanks, Ember
1
1649
by: Jonathan & Maricel Espejo | last post by:
Hi, Could somebody confirm what is the maximum size of shared memory that can be allocated for DB2 on Windows 2000 Servers. I heard that its about 2GB. Is the 2GB shared memory limit applies to what per DATABASE or per INSTANCE? Your input would be highly appreciated. Regards, Maricel
1
1820
by: ggnanaraj | last post by:
On Unix, how can we calculate the shared memory currently being used by the database instance. Reason for this is that we have a limit to the size of shared memory that can be configured for use by the database. eg., Linux 1.74 GB per instance; Solaris 3.5 GB, etc... TIA.
3
3150
by: sadanjan | last post by:
Hi , Appreciate if someone can clarify if database Share Memory Limit (2 GB ) in Unix 32 bit boxes is the top limit for all the databases put together in a database or is it for each of the database in an Instance Thanks & regards sadanjan
1
2415
by: landacorp | last post by:
Hi, everyone! I am having trouble with values stored into the shared memory. Either i create "shmop_write" the value into the segment by cron and i being able to get it from the memory from command prompt ONLY with "/ usr/local/bin/php -q -f test.php", or i create the same way and the same segment (after freeing the momory) inside browser through apache and the value is available for command prompt and apache BOTH. The question is -...
0
8974
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9500
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9218
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8227
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6060
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3292
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.