473,321 Members | 1,877 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,321 software developers and data experts.

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($segment_key, $segment_size, $segment_perms);
shm_put_var($shm_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 3864
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
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,...
0
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...
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...
3
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...
14
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...
1
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...
1
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...
3
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.