新尝试访问0x00000000? [英] New trying to access 0x00000000?

查看:81
本文介绍了新尝试访问0x00000000?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一整天都想弄清楚这一点.

Been trying to figure this one out all day.

...
_HISTORY tempHist;
for(int i = 0; i < info.LogPerRecs; i++)
{
        CString msg;
        msg.Format("History #%d being allocated..",i);
	log.Write_Log_File(msg);
	tempHist = new History();
	msg.Format("New History allocated at %d",tempHist);
	log.Write_Log_File(msg);
...



日志说...
"
2010年7月22日13:39:56>已分配历史记录20..
2010年7月22日13:39:56>开始历史构造函数
2010年7月22日13:39:56>完成历史构造函数
2010年7月22日13:39:56>分配给13046208的新历史记录
07/22/2010 13:39:56>分配了历史记录21..
2010年7月22日13:39:56>开始历史构造函数
2010年7月22日13:39:56>完成历史构造函数
2010年7月22日13:39:56>分配了新历史记录的13046384
07/22/2010 13:39:56>分配了历史记录22..
"

然后它爆炸并显示一个错误,
"0x7c911689"处的指令引用了"0x00000000"处的存储器.该存储器无法读取""

但是,我的日志语句之间唯一的代码段是动态分配,从我以前分配的地址来看,我并没有完全在地址上刮掉桶的底部.

历史记录类包含大约35个浮点数,里面没有任何巧妙的内容,_HISTORY是指向该历史记录类的指针的typedef.

代码在调试中工作良好,已发布版本.有什么想法吗?



Log says...
"
07/22/2010 13:39:56>History #20 being allocated..
07/22/2010 13:39:56>Beginning History Constructor
07/22/2010 13:39:56>Finishing History Constructor
07/22/2010 13:39:56>New History allocated at 13046208
07/22/2010 13:39:56>History #21 being allocated..
07/22/2010 13:39:56>Beginning History Constructor
07/22/2010 13:39:56>Finishing History Constructor
07/22/2010 13:39:56>New History allocated at 13046384
07/22/2010 13:39:56>History #22 being allocated..
"

And then it blows up with an error that says,
"The instruction at "0x7c911689" referenced memory at "0x00000000". The memory could not be "read""

Yet the only blob of code between my log statements is the dynamic allocation, and judging by the addresses of my previous allocations, I''m not exactly scraping the bottom of the barrel on addresses.

History class contains about 35 floats, nothing clever whatsoever inside of it, _HISTORY is a typedef for a pointer to said History class.

Code works fine in debug, has kittens in release. Any thoughts?

推荐答案

如果只有两个类(日志写入器,历史记录),请验证内存分配/构造函数和释放/析构函数.您可能错误地初始化/释放了动态分配的内存块.

或也发布这些类.

您还可以分析minidump文件(您将需要.PDB文件来执行此操作.).
If you have only two classes (log writter, History) verify memory allocations/constructors and deallocations/destructors. You are propably incorrectly initializing/freeing a dynamically allocated block of memory.

Or publish these classes too.

You can also analyze minidump file (you will need .PDB files to do this).


在循环的每次迭代中,您都为历史记录分配了一些内存
tempHist =新的History();
您是否正在占用此内存并在其他一些功能中使用它?
如果此内存在每次循环迭代后不再使用,则可以在每次循环迭代结束时删除它.
否则,它将根据循环迭代次数和历史记录的大小而耗尽内存
如下代码可能会有所帮助
in each iteration of the loop you are allocating some memeory for History
tempHist = new History();
are you taking this memory and using somewhere in some other function?
if this memory is no longer used after each loop iteration, you can delete this at the end of each loop iteration.
otherwise it will go out of memory depending on number of loop iteration and size of History
code as below may help
...
_HISTORY tempHist;
for(int i = 0; i < info.LogPerRecs; i++)
{
        CString msg;
        msg.Format("History #%d being allocated..",i);
	log.Write_Log_File(msg);
	tempHist = new History();
	msg.Format("New History allocated at %d",tempHist);
	log.Write_Log_File(msg);
...
...
        delete tempHist;
        tempHist = 0;
}


通常在调试中可以正常使用但在发行版中不起作用的代码有一些问题:
1.未初始化的变量-调试器将自动初始化所​​有变量,但是在发布模式下情况并非如此,请确保所有变量都已正确初始化.
2.数组溢出-调试器将数组分配稍大一些以方便调试过程(即能够在不导致调试版本崩溃的情况下查找溢出),但再次,发行版不执行此操作.

快速的问题,这是多线程的吗? ...可能会使事情更加复杂....
Usually code that works fine in debug but doesn''t work in release has a few problems:
1. Uninitialized variables- the debugger will auto-initialize all variables, but this is not the case in release mode, make sure all variables are properly initialized.
2. Array overflow- the debugger makes array allocations slightly bigger to facilitate debugging process (i.e. be able to find overflows without having the debug version crash), but again, release version does not do that.

Quick question, is this multi-threaded? ...that could further complicate things....


这篇关于新尝试访问0x00000000?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆