在释放内存时,崩溃了,出现了如下错误:
User breakpoint called from code at 0x7c921230
Debug Assertion Failed! Program:...
File: dbgheap.c
Line: 1011 Expression: _CrtIsValidHeapPointer(出现问题的指针)
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
如果点击忽略,则继续弹出对话框 Debug Error! Program:...
DAMAGE: after Normal block (#4826967) at 0x2000E148.
(Press Retry to debug the application)
正如上次所述(http://hi.baidu.com/ablenavy/blog/item/6092524e88ff020db2de0516.html)
(DAMAGE:after Normal block的解决方法)
这次的原因依然是内存申请得太小!
具体代码如下:
#define P2Node_LEN_1 (1024 * 10)
#define P2Node_LEN_2 1024 // Sct_Node是一个结构体
Sct_Node **p2Node; //定义一个指向Sct_Node的指针的指针,相当于二维数组。
// 空间申请
p2Node = (Sct_Node **)malloc(P2Node_LEN_1 * sizeof(Sct_Node *));
for (int i = 0; i < P2Node_LEN_1; i++)
{
p2Node[i] = (Sct_Node *)malloc(P2Node_LEN_2 * sizeof(Sct_Node));
}
// 向p2Node插入数据
pSharedData->p2Node[i][j] = sct_Node; // 释放空间
for ( int i = 0; i < P2Node_LEN_1; i++ )
{
free( p2Node[i] ); //经调试,在该语句中出现崩溃。
}
free( p2Node );
经跟踪程序发现,在向p2Node插入数据时,j的值超过了1024,但可以正常插入,不会出现错误,等释放空间时才出现错误。
解决办法:
将 #define P2Node_LEN_2 1024 改为:
#define P2Node_LEN_2 (1024 * 10)
如何从根本上消除这种错误?!
其实很简单,在插入时加入边界检查,如下:
将插入语句:
pSharedData->p2Node[i][j] = sct_Node;
改为:
if ( j >= P2Node_LEN_2 )
{
cout << "Error! Out of memory! P2Node_LEN_2 is too small" << endl;
exit(1);
}
pSharedData->p2Node[i][j] = sct_Node;
这样就可以避免出现上述的崩溃现象了。
分享到:
相关推荐
安装npm install monthly-damage用法var monthlyDamage = require('monthly-damage');monthlyDamage({ price: 400000, downPayment: 80000, interestRatePercent: 4.125, termInYears: 30, monthlyCondoFee: 250, ...
[Material_State2,D]=Elastic_Plastic_Ductile_Damage_Model(Material,Material_State,e) 输入: 材料:包含材料属性 Material.E(弹性模量)、Material.v(泊松比)、Material.f_y(屈服应力)、Material.g_f...
身体伤害表示一个图解的玩家,以显示玩家死亡时敌人对玩家的身体部位造成的伤害
远古伤害 研究古代dna的破坏
使用脚本Data_prep.R中的ba.csv和Damage.csv准备数据 在analysis.csv中使用准备好的数据在脚本Analysis.R中执行引导程序分析 描述 分析 ba.csv和damage.csv是与LTSP实验中的2009年森林清单和2011年森林破坏评估相...
*MAT_Concrete_Damage_Rel3参数
介绍该模块为(至少一些)i.MX6 电子纸帧缓冲区提供用户空间损坏跟踪。 它已经在使用 i.MX6 SoloLite 的上进行了测试。 由于电子纸显示器具有非常高的更新延迟,这取决于更新区域的大小,因此打算在此类显示器上运行...
CSGO-控制台-解析器 ... Total Damage: 142 in 2 hits Damage Received: PLAYER_NAME_ONE: 74 in 4 hits PLAYER_NAME_TWO: 208 in 2 hits Total Damage: 282 in 6 hits 配置 确保使用-condebug启动参数运行CSGO
Ultimate Text Damage 1.1.2.unitypackage
This study proposes a new PSOS-model based damage identification procedure using frequency domain data. The formulation of the objective function for the minimization problem is based on the Frequency...
this code is related to isotropic plasticity model damage problem
胫骨派对会话计算器 Discord bot 用于在狩猎浪费或获利后计算每一方成员分配的份额数量 机器人链接 用法 使用命令!share 来获取您可以在聚会上共享经验的一系列级别 使用命令!... Damage: 267,928 Hea
User subroutine UMAT for modeling the damage initiation and evolution in the fiber-reinforced epoxy layers.
element model in conjunction with a recently proposed damage detection technique, referred to as the adaptive quadratic sum-square error with unknown inputs (AQSSE-UI). The identification process is ...
损伤力学数值模型,Numerical-modelling-in-damage-mechanics,资源来自花联网
Bearing-Damage-Analysis-Reference-Guide.pdf
umat for damage behavior of 1d beam
Umat for GTN damage model in Abaqus
LeCun于1989年提出有关于深度学习在未来可能发展的大规模的参数和层数进行压缩的想法,并进行了一定实验。为后续对深度学习模型压缩提出的基础理论。