shmop 问题

xysmc1 2009-11-09 11:24:06
shmop建立共享内存后,怎么也不能清空,我试验了两种方法都不行
一种测试方法是:
$intKey=1234;
$intLength=12;
$strValue1="abcdefg";
$strValue2="33";

$intShmopId=shmop_open($intKey,"c",0666,$intLength) ;
shmop_write($intShmopId,$strValue1,0);
shmop_delete($intShmopId);
shmop_close($intShmopId);

$intShmopId=shmop_open($intKey,"w",0666,$intLength) ;
shmop_write($intShmopId,$strValue2,0);
$strResult=shmop_read($intShmopId,0,$intLength);
shmop_close($intShmopId);
echo $strResult;//这里的输出结果是333456

第二种方法:
$intKey=1234555;
$intLength=12;
$strValue1="abcdefg";
$strValue2="33";

$intShmopId=shmop_open($intKey,"c",0666,$intLength) ;
for($i=0;$i<$intLength;$i++)
{
shmop_write($intShmopId,"",$i);

}
shmop_close($intShmopId);

$intShmopId=shmop_open($intKey,"w",0666,$intLength) ;
shmop_write($intShmopId,$strValue2,0);
$strResult=shmop_read($intShmopId,0,$intLength);
shmop_close($intShmopId);
echo $strResult;//这里的输出结果还是是333456

请问这是怎么回事?
...全文
145 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xysmc1 2009-11-17
  • 打赏
  • 举报
回复
不好意思,这两天忙,没上线,总的来说我已经对shmop绝望了,用了其他的方法。
给分了。
Siramizu 2009-11-12
  • 打赏
  • 举报
回复
第二种方法5.2.9-1测试通过
你的php什么版本
xysmc1 2009-11-12
  • 打赏
  • 举报
回复
再自己顶一下,把问题重申一遍:

shmop建立共享内存后,怎么也不能清空,我试验了两种方法都不行
一种测试方法是:
$intKey=1234;
$intLength=12;
$strValue1="abcdefg";
$strValue2="33";

$intShmopId=shmop_open($intKey,"c",0666,$intLength) ;
shmop_write($intShmopId,$strValue1,0);
shmop_delete($intShmopId);
shmop_close($intShmopId);

$intShmopId=shmop_open($intKey,"w",0666,$intLength) ;
shmop_write($intShmopId,$strValue2,0);
$strResult=shmop_read($intShmopId,0,$intLength);
shmop_close($intShmopId);
echo $strResult;//输出的结果都是33cdefg

第二种方法:
$intKey=1234555;
$intLength=12;
$strValue1="abcdefg";
$strValue2="33";

$intShmopId=shmop_open($intKey,"c",0666,$intLength) ;
for($i=0;$i <$intLength;$i++)
{
shmop_write($intShmopId,"",$i);

}
shmop_close($intShmopId);

$intShmopId=shmop_open($intKey,"w",0666,$intLength) ;
shmop_write($intShmopId,$strValue2,0);
$strResult=shmop_read($intShmopId,0,$intLength);
shmop_close($intShmopId);
echo $strResult;//这里的输出结果还是33cdefg请问这是怎么回事?



4楼说的也我也看了,但是还是不能最终解决问题,多次试验表明,在WINDOWS2003、WINDOWS XP系统下,shmop_delete清空不了内存块,但是我用循环的方法调用shmop_write(见方法二),向内存中写入空值,也写不进去,真是无能为力了。
xysmc1 2009-11-09
  • 打赏
  • 举报
回复
不好意思,打错了,两次输出的结果都是33cdefg
xysmc1 2009-11-09
  • 打赏
  • 举报
回复
怎么没有把值读到$strResult呢?,此话怎讲?
Siramizu 2009-11-09
  • 打赏
  • 举报
回复
你不是把值读到$strResult里面了
Siramizu 2009-11-09
  • 打赏
  • 举报
回复
看看这个bug是否和你的情况相同http://bugs.php.net/bug.php?id=33011

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧