More Effective Use of Shared Memory on Linux
An anonymous reader writes "Making effective use of shared memory in high-level languages such as C++ is not straightforward, but it is possible to overcome the inherent difficulties. This article describes, and includes sample code for, two C++ design patterns that use shared memory on Linux in interesting ways and open the door for more efficient interprocess communication."
Imemcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Java, in which everything is an object except for primitives and it takes ten classes and wrappers just to read a file,
Eh?
File inputFile = new File("temp.txt");
FileReader in = new FileReader(inputFile);
Or if you want to use the new IO library from 1.4 which gives you memory mapping and locking on sections of files,
FileChannel in = new FileInputStream("temp.txt").getChannel();
Being bitter is drinking poison and hoping someone else will die
Hi! /. crowd would help me...
/var/www/html/sharedmem.php on line 2
// These are fine
/*$shm_size = shmop_size($shm_id); // Now lets read the string back
I have a prob with shared memory in PHP and C++ I thought the
I have a server written in C++ and my webpages are in PHP. The PHP has to communicate with the server using shared memory. This was working fine on the server running FC-1 with php-4.3.8. We recently migrated to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it displays is as follows:
shmop_open(): unable to attach or create shared memory segment in
The server opens the shm in 666 (originally was 644) even then it was not working. I can see the shared mem open using 'ipcs' command.
The source code of PHP is as follows:
";
# print $shm_key;
$shm_id = shmop_open($shm_key, "a",0,0) or die("FATAL ERROR:: Unable to Access Shared Memory");
DEBUG:: print ("Shared Memory Block Size: " . $shm_size."\n");
*/
$data = shmop_read($shm_id, 0, $shm_size);
if (!$data) {
echo "FATAL ERROR:: Couldn't read from shared memory\n";
exit;
}
?>
Both the configs say that 'shmop' is enabled.
Can some one help me with this, I am in desperate need of this, if this fails I might have to search for an alternative and the project has to go live in a week or so. I am in desperate need of help, can any one help pls?
Regards,
Yaswanth