PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Shared Memory> <Semaphore Functions
Last updated: Fri, 10 Oct 2008

view this page in

shm_remove

(PHP 4, PHP 5)

shm_removeRemoves shared memory from Unix systems

Description

bool shm_remove ( int $shm_identifier )

shm_remove() removes the shared memory shm_identifier . All data will be destroyed.

Parameters

shm_identifier

The shared memory identifier as returned by shm_attach()

Return Values

Returns TRUE on success or FALSE on failure.

See Also



add a note add a note User Contributed Notes
shm_remove
aaron DURP segura DURP gmail DURP com
20-Aug-2006 12:55
It appears that you must be connected to the shm segment in order to remove it.

<?php
shm_remove
($shm);
shm_detach($shm);
?>

works, while

<?php
shm_detach
($shm);
shm_remove($shm);
?>

produces "Warning: shm_remove(): The parameter is not a valid shm_identifier ..."
cu at ulakbim dot gov dot tr
30-Dec-1999 04:30
Though it says **shm_identifier** in
  int shm_remove(int shm_identifier);
and
  shm_attach() returns an **id** that that can be used to access the System V...

a snippet like this:
<?php
  $key
= 1234;
 
$shm=shm_attach($key);
 
// do whatever...
 
shm_remove($shm);
?>

produces an error like
Warning: 2(which is the value of $shm) is not a existing SysV shared memory key in /usr/cu/web/sema.php on line 44...

The documentation confused me a bit. I thought shm_remove would get the shm handle/id that returns from shm_attach, not the key given to shm_attach. So, use instead:
  shm_remove($key);

which is what is intended indeed.

Shared Memory> <Semaphore Functions
Last updated: Fri, 10 Oct 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites