NSMutableDictionary中的对象突然变为空(Object in NSMutableDictionary suddenly becomes null)
更新:
我添加了一个检查字典中的空对象的方法,事实上,他们被发现:
有没有人见过类似的东西? 这不能由不正确的内存管理引起。 请注意,左侧的字典对象树实际上是正确的。
结束更新
我在启用ARC的情况下向
NSMutableDictionary
添加了一些条目。 添加其中一个之后,突然添加的对象变为空。 这里的代码(我扩大它,以确保我没有发疯):NSMutableDictionary *base = [NSMutableDictionary dictionary]; id o = [GAConstant kTRUE]; id k = [GAClause parse:@"(x 1 1)"]; [base setObject:o forKey:k]; NSLog(@"### Added (%@ -> %@): %@", k, o, base); o = [GAClause parse:@"(y X)"]; k = [GAClause parse:@"(x 2 X)"]; [base setObject:o forKey:k]; NSLog(@"### Added (%@ -> %@): %@", k, o, base); o = [GAConstant kTRUE]; k = [GAClause parse:@"(y 3)"]; [base setObject:o forKey:k]; NSLog(@"### Added (%@ -> %@): %@", k, o, base); o = [GAConstant kTRUE]; k = [GAClause parse:@"(y 6)"]; [base setObject:o forKey:k]; NSLog(@"### Added (%@ -> %@): %@", k, o, base);
这是输出:
2013-03-25 16:10:33.546 Jungle[1978:11303] ### Added (<GAListClause: 0x75b0dc0> -> <GAConstant: 0x75b12b0>): { "<GAListClause: 0x75b1b00>" = "<GAConstant: 0x75b12b0>"; } 2013-03-25 16:10:33.548 Jungle[1978:11303] ### Added (<GAListClause: 0x75b2870> -> <GAListClause: 0x75b1aa0>): { "<GAListClause: 0x75b2270>" = "<GAListClause: 0x75b1aa0>"; "<GAListClause: 0x75b1b00>" = "<GAConstant: 0x75b12b0>"; } 2013-03-25 16:10:33.549 Jungle[1978:11303] ### Added (<GAListClause: 0x75b2b90> -> <GAConstant: 0x75b12b0>): { "<GAListClause: 0x75b2d80>" = "<GAConstant: 0x75b12b0>"; "<GAListClause: 0x75b2270>" = "<GAListClause: 0x75b1aa0>"; "<GAListClause: 0x75b1b00>" = "<GAConstant: 0x75b12b0>"; } 2013-03-25 16:10:33.550 Jungle[1978:11303] ### Added (<GAListClause: 0x75b2f00> -> <GAConstant: 0x75b12b0>): { "<GAListClause: 0x75b2d80>" = "<GAConstant: 0x75b12b0>"; "<GAListClause: 0x75b2270>" = "<GAListClause: 0x75b1aa0>"; "<GAListClause: 0x75b1b00>" = "<GAConstant: 0x75b12b0>"; "<GAListClause: 0x75b1d60>" = (null); }
方法
[GAConstant kTRUE]
初始化并返回一个静态变量。[GAClause parse:]
每次都会返回一个新的解析对象。很明显,为什么
k
变量的地址不符合字典的内容:它会复制它们。 仍然不清楚null是如何潜入其中的。 字典中null的位置会随着每次运行而改变,有时我会得到其中的两个。看起来内存管理正在发生,但是什么? ARC在此处启用。
以下是与
[GAConstant kTRUE]
方法相关的代码:+ (GAConstant *)kTRUE { static GAConstant *kTRUE = nil; static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ kTRUE = [[GAConstant alloc] initWithString:@"true"]; }); return kTRUE; }
有时零字在字典中波动:
2013-03-25 17:09:16.426 Jungle[2294:11303] ### Added (<GAListClause: 0x7182ce0> -> <GAConstant: 0x7183430>): { "<GAListClause: 0x7183a30>" = "<GAConstant: 0x7183430>"; } 2013-03-25 17:09:16.428 Jungle[2294:11303] ### Added (<GAListClause: 0x75467b0> -> <GAListClause: 0x71839d0>): { "<GAListClause: 0x7546a30>" = (null); "<GAListClause: 0x7183a30>" = "<GAConstant: 0x7183430>"; } 2013-03-25 17:09:16.429 Jungle[2294:11303] ### Added (<GAListClause: 0x7546cd0> -> <GAConstant: 0x7183430>): { "<GAListClause: 0x7546ec0>" = "<GAConstant: 0x7183430>"; "<GAListClause: 0x7546a30>" = "<GAListClause: 0x71839d0>"; "<GAListClause: 0x7183a30>" = "<GAConstant: 0x7183430>"; } 2013-03-25 17:09:16.430 Jungle[2294:11303] ### Added (<GAListClause: 0x7547040> -> <GAConstant: 0x7183430>): { "<GAListClause: 0x75470f0>" = (null); "<GAListClause: 0x7546ec0>" = "<GAConstant: 0x7183430>"; "<GAListClause: 0x7546a30>" = "<GAListClause: 0x71839d0>"; "<GAListClause: 0x7183a30>" = "<GAConstant: 0x7183430>"; }
以下是它在调试器中的样子:
Update:
I have added a method that checks for null objects in dictionary and indeed, they were found:
Did anyone ever seen anything like this? This can't be caused by incorrect memory management. Note that dictionary object tree on the left is actually correct.
End update
I'm adding a number of entries to the
NSMutableDictionary
with ARC enabled. After one of the additions the object added suddenly becomes null. Here's the code (I expanded it to make sure I haven't gone mad):NSMutableDictionary *base = [NSMutableDictionary dictionary]; id o = [GAConstant kTRUE]; id k = [GAClause parse:@"(x 1 1)"]; [base setObject:o forKey:k]; NSLog(@"### Added (%@ -> %@): %@", k, o, base); o = [GAClause parse:@"(y X)"]; k = [GAClause parse:@"(x 2 X)"]; [base setObject:o forKey:k]; NSLog(@"### Added (%@ -> %@): %@", k, o, base); o = [GAConstant kTRUE]; k = [GAClause parse:@"(y 3)"]; [base setObject:o forKey:k]; NSLog(@"### Added (%@ -> %@): %@", k, o, base); o = [GAConstant kTRUE]; k = [GAClause parse:@"(y 6)"]; [base setObject:o forKey:k]; NSLog(@"### Added (%@ -> %@): %@", k, o, base);
Here's the output:
2013-03-25 16:10:33.546 Jungle[1978:11303] ### Added (<GAListClause: 0x75b0dc0> -> <GAConstant: 0x75b12b0>): { "<GAListClause: 0x75b1b00>" = "<GAConstant: 0x75b12b0>"; } 2013-03-25 16:10:33.548 Jungle[1978:11303] ### Added (<GAListClause: 0x75b2870> -> <GAListClause: 0x75b1aa0>): { "<GAListClause: 0x75b2270>" = "<GAListClause: 0x75b1aa0>"; "<GAListClause: 0x75b1b00>" = "<GAConstant: 0x75b12b0>"; } 2013-03-25 16:10:33.549 Jungle[1978:11303] ### Added (<GAListClause: 0x75b2b90> -> <GAConstant: 0x75b12b0>): { "<GAListClause: 0x75b2d80>" = "<GAConstant: 0x75b12b0>"; "<GAListClause: 0x75b2270>" = "<GAListClause: 0x75b1aa0>"; "<GAListClause: 0x75b1b00>" = "<GAConstant: 0x75b12b0>"; } 2013-03-25 16:10:33.550 Jungle[1978:11303] ### Added (<GAListClause: 0x75b2f00> -> <GAConstant: 0x75b12b0>): { "<GAListClause: 0x75b2d80>" = "<GAConstant: 0x75b12b0>"; "<GAListClause: 0x75b2270>" = "<GAListClause: 0x75b1aa0>"; "<GAListClause: 0x75b1b00>" = "<GAConstant: 0x75b12b0>"; "<GAListClause: 0x75b1d60>" = (null); }
The method
[GAConstant kTRUE]
initializes and returns a static variable.[GAClause parse:]
returns a new parsed object every time.It's clear why addresses of
k
variables do not correspond to the contents of the dictionary: it copies them. Still not clear how a null can sneak in as a value. The location of null in the dictionary changes with every run, sometimes I'm getting two of them.Looks like something is going on with the memory management, but what? ARC is enabled here.
Here's the code relevant to
[GAConstant kTRUE]
method:+ (GAConstant *)kTRUE { static GAConstant *kTRUE = nil; static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ kTRUE = [[GAConstant alloc] initWithString:@"true"]; }); return kTRUE; }
Sometimes null is fluctuating across the dictionary:
2013-03-25 17:09:16.426 Jungle[2294:11303] ### Added (<GAListClause: 0x7182ce0> -> <GAConstant: 0x7183430>): { "<GAListClause: 0x7183a30>" = "<GAConstant: 0x7183430>"; } 2013-03-25 17:09:16.428 Jungle[2294:11303] ### Added (<GAListClause: 0x75467b0> -> <GAListClause: 0x71839d0>): { "<GAListClause: 0x7546a30>" = (null); "<GAListClause: 0x7183a30>" = "<GAConstant: 0x7183430>"; } 2013-03-25 17:09:16.429 Jungle[2294:11303] ### Added (<GAListClause: 0x7546cd0> -> <GAConstant: 0x7183430>): { "<GAListClause: 0x7546ec0>" = "<GAConstant: 0x7183430>"; "<GAListClause: 0x7546a30>" = "<GAListClause: 0x71839d0>"; "<GAListClause: 0x7183a30>" = "<GAConstant: 0x7183430>"; } 2013-03-25 17:09:16.430 Jungle[2294:11303] ### Added (<GAListClause: 0x7547040> -> <GAConstant: 0x7183430>): { "<GAListClause: 0x75470f0>" = (null); "<GAListClause: 0x7546ec0>" = "<GAConstant: 0x7183430>"; "<GAListClause: 0x7546a30>" = "<GAListClause: 0x71839d0>"; "<GAListClause: 0x7183a30>" = "<GAConstant: 0x7183430>"; }
Here's what it looks like in the debugger:
原文:https://stackoverflow.com/questions/15620084
最满意答案
问题的答案是doynax发送的回复 :
"I believe there is a shim in recent versions of Windows limiting the available DPMI memory to 32 MB, for yet more ancient software incapable of unprepared such wast quantities of RAM. You may try creating a DpmiLimit key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WOW in the registry to adjust this with the limit in bytes as a DWORD"
The answer to the question is the reply sent by doynax:
"I believe there is a shim in recent versions of Windows limiting the available DPMI memory to 32 MB, for yet more ancient software incapable of unprepared such wast quantities of RAM. You may try creating a DpmiLimit key under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WOW in the registry to adjust this with the limit in bytes as a DWORD"
相关问答
更多-
你可以使用php -d memory_limit=-1 artisan migrate来临时绕过内存限制。 You can use php -d memory_limit=-1 artisan migrate to temporary bypass memory limits.
-
问题的答案是doynax发送的回复 : "I believe there is a shim in recent versions of Windows limiting the available DPMI memory to 32 MB, for yet more ancient software incapable of unprepared such wast quantities of RAM. You may try creating a DpmiLimit key under HKEY_LOC ...
-
而不是在htaccess中更改内存限制,你应该在php ini文件中进行。 寻找这一行:php_value memory_limit 如果您在共享主机上,您可能会发现他们必须为您提供帮助。 如果你在共享主机上,祝你好运:)我发现在我尝试过的每个共享主机上运行购物车都是噩梦。 值得每个月额外的一点VPS至少。 Instead of changing your memory limit in htaccess you should do it in in the php ini file. Look for t ...
-
Git Init --Bare Error - 致命:内存不足?(Git Init --Bare Error - fatal: Out of memory? mmap failed: No such device)[2023-10-18]
您的“裸机”回购中是否有名为“config”的目录/文件? 见http://www.bitchx.com/log/git-f/git-f-20-Mar-2010/git-f-20-M-2010-2010.php ( 镜像 ) 编辑:如果是这样,你几乎可以肯定不会使用git init --bare - bare意味着你打算推入的空的 “服务器”存储库,而不是用于从工作树初始化新的存储库。 Do you have a directory/file named "config" in your "bare" re ... -
尝试这个 :
致命错误:允许的内存大小(Fatal error: Allowed memory size)[2023-09-11]
我在我的图像处理类中做过的事情就是在创建一个新图像之后(例如在resize()方法中)破坏原始图像。 尝试将resize()方法更改为此 function resize($width,$height) { $new_image = imagecreatetruecolor($width, $height); imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), ...加载'mingw-0.9.3-0'时“dos:内存分配错误”(“dos: Memory allocation error” while loading 'mingw-0.9.3-0')[2023-03-27]
我也有一段时间与这个问题作斗争。 似乎是win10机器上stacksize函数的不兼容性。 这个修复对我有用: 找到mingw.start文件,它可能位于“scilab-5.5.2 \ contrib \ mingw \ 0.9.3-0 \ etc”目录中。 使用stacksize('max')顺序通过在行前面放置“//”来注释#49行 开始scilab,在第一次运行scilab与mingw建立一些libs所以它需要比平时更多的时间 I'm also fighting with this problem f ...我认为你有一个新的PHP版本,你在你的例子中使用引用。 if(!$sock = @fsockopen($this->_whois, $this->_port, &$errno, &$errstr, 10)) 删除$errno和$errstr之前的& 。 if(!$sock = @fsockopen($this->_whois, $this->_port, $errno, $errstr, 10)) 我认为你在PHP文档中看到的是这个 resource fsockopen ( string $hostna ...你正遭受爆炸行数组合的爆炸。 看看这个问题 ,它以较小的规模描述了同样的问题。 基本上,您正在运行具有多个一对多连接的大型查询,类似于: SELECT ... FROM `User` `t` LEFT JOIN `Route` routes ON t.id = routes.author_id LEFT JOIN `Question` questions ON t.id = questions.author_id LEFT JOIN `Comment` comments ON t.id = c ...GLUT:致命错误:内存不足(GLUT: Fatal Error: out of memory)[2022-03-12]
检查文件的编码( http://lists.apple.com/archives/mac-opengl/2006/Jun/msg00070.html ) 确保您使用的是相同的运行时环境(您是否在笔记本电脑上安装了相同的glut.dll?) 最后,我有一个问题:你是什么意思“通过Visual Studio运行应用程序”? 你按Ctrl + F5? I found the solution, it is rather dumb. I had set up "main" as "Entry Point" in " ...相关文章
更多- List用完后需要赋null吗
- 判断对象是否为空。
- Guava学习笔记:Optional优雅的使用null
- 如何将sql数据库值默认为空而不是null
- Guava Optional类详解-处理null值
- spring注解注入的对象为空
- Solr Document [null] missing required field: id 的原因
- ssh2整合 spring 注入对象为空
- 命令行运行Hbase: Session 0x0 for server null, unexpected error
- Hibernate创建sessionFactory null
最新问答
更多- python的访问器方法有哪些
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。
- 响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
- 在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
- NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
元素上的盒子阴影行为(box-shadow behaviour on elements) - Laravel检查是否存在记录(Laravel Checking If a Record Exists)
- 设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
- 想学Linux 运维 深圳有哪个培训机构好一点
- 为什么有时不需要在lambda中捕获一个常量变量?(Why is a const variable sometimes not required to be captured in a lambda?)
- 在Framework 3.5中使用服务器标签<%=%>设置Visible属性(Set Visible property with server tag <%= %> in Framework 3.5)
- AdoNetAppender中的log4net连接类型无效(log4net connection type invalid in AdoNetAppender)
- 错误:发送后无法设置标题。(Error: Can't set headers after they are sent. authentication system)
- 等待EC2实例重启(Wait for an EC2 instance to reboot)
- 如何在红宝石中使用正则表达式?(How to do this in regex in ruby?)
- 使用鼠标在OpenGL GLUT中绘制多边形(Draw a polygon in OpenGL GLUT with mouse)
- 江民杀毒软件的KSysnon.sys模块是什么东西?
- 处理器在传递到add_xpath()或add_value()时调用了什么顺序?(What order are processors called when passed into add_xpath() or add_value()?)
- sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
- 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
- AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
- SQL查询,其中字段不包含$ x(SQL Query Where Field DOES NOT Contain $x)
- PerSession与PerCall(PerSession vs. PerCall)
- C#:有两个构造函数的对象:如何限制哪些属性设置在一起?(C#: Object having two constructors: how to limit which properties are set together?)
- 平衡一个精灵(Balancing a sprite)
- n2cms Asp.net在“文件”菜单上给出错误(文件管理器)(n2cms Asp.net give error on Files menu (File Manager))
- Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
- 湖北京山哪里有修平板计算机的