PHP: shmop_delete - Manual

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

search for in the

shmop_open shmop_close

Last updated: Sat, 27 Jan 2007

view this page in

# shmop_delete

(PHP 4 >= 4.0.4, PHP 5)

shmop_delete -- Delete shared memory block

## Описание

bool shmop_delete ( int shmid )

shmop_delete() is used to delete a shared memory block.

## Список параметров

`shmid`

  The shared memory block identifier created by shmop_open()

## Возвращаемые значения

Возвращает `TRUE` в случае успешного завершения или `FALSE` в случае возникновения ошибки.

## Примеры

Пример 1. Deleting shared memory block

`<?php shmop_delete($shm_id); ?>`

This example will delete shared memory block identified by `$shm_id`.

add a note User Contributed Notes
shmop_delete
lizzy
12-Oct-2004 07:19
`A helpful hint, although when using shmop on windows (yes you can use shmop on windows in IIS or Apache when used as isapi/module) you can delete a segment and later open a new segment with the SAME KEY in the same script no problem, YOU CANNOT IN LINUX/UNIX - the segment will still exist - it's not immediately deleted - but will be marked for deletion and you'll get errors when trying to create the new one - just a reminder.`
slavapl at mailandnews dot com
02-May-2001 12:27
`There is an important factor to keep in mind here, the shmop_delete function doesn't actually "delete" the memory segment per say, it MARKS the segment for deletion. An shm segment can not be deleted while there are processes attached to it, so a call to shm_delete will two things, first no other processes will be allowed to attach to the segment after this call, and also, it will mark the segment for deletion, which means that when all current processes mapping the segment detach (shmop_close) the system will automatically delete the segment.
So, again, the proper way to close and delete an shm segement is:
$shmid = shmop_open(...);
(do something with the block here: read, write, whatever)
shmop_delete($shmid);
shmop_close($shmid);
you must call the shmop_delete before you call shmop_close for reasons outlined above.
Also to mark a segment for deletion you must be root or the owner.
A few notes from the linux manpage on shmctl:
IPC_RMID (the flag used in shmop_delete):
is used to mark the segment as destroyed. It will actually be destroyed after the last detach. (I.e., when the shm_nattch member of the associated structure shmid_ds is zero.) The user must be the owner, creator, or the super-user.
***
The user must ensure that a segment is eventually destroyed; otherwise its pages that were faulted in will remain in memory or swap.
***`
add a note
shmop_open shmop_close

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST