我最近遇到了一个记忆问题,我对此很新,所以希望有人能给我一些指示。
弹出窗口显示
ParticleSystemJames.exe中0x759fc41f处的未处理异常:Microsoft C ++异常:内存位置为0x0017ec78的std :: bad_alloc ..
VS2010调试模式下的堆栈跟踪:
KernelBase.dll!759fc41f()
[Frames below may be incorrect and/or missing, no symbols loaded for KernelBase.dll]
KernelBase.dll!759fc41f()
msvcr100d.dll!_unlock(int locknum) Line 375 C
msvcr100d.dll!_unlockexit() Line 785 + 0x7 bytes C
msvcr100d.dll!_CxxThrowException(void * pExceptionObject, const _s__ThrowInfo * pThrowInfo) Line 157 C++
msvcr100d.dll!operator new(unsigned int size) Line 64 C++
ParticleSystemJames.exe!std::_Allocate<SpringLink *>(unsigned int _Count, SpringLink * * __formal) Line 36 + 0x15 bytes C++
ParticleSystemJames.exe!std::allocator<SpringLink *>::allocate(unsigned int _Count) Line 187 + 0xb bytes C++
ParticleSystemJames.exe!std::deque<SpringLink,std::allocator<SpringLink> >::_Growmap(unsigned int _Count) Line 1599 + 0x15 bytes C++
ParticleSystemJames.exe!std::deque<SpringLink,std::allocator<SpringLink> >::push_back(const SpringLink & _Val) Line 1265 + 0x34 bytes C++>
ParticleSystemJames.exe!ParticleSystem::createLink(Particle * p1_ptr, Particle * p2_ptr, _Material material) Line 128 C++
ParticleSystemJames.exe!createVoxel(int p_x_idx, int p_y_idx, int p_z_idx, _Material p_material, double p_voxelEdgeLen) Line 358 C++
ParticleSystemJames.exe!addPoints() Line 226 + 0x4f bytes C++
ParticleSystemJames.exe!runSimulation() Line 654 C++
ParticleSystemJames.exe!main(int argc, char * * argv) Line 708 C++
ParticleSystemJames.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C
ParticleSystemJames.exe!mainCRTStartup() Line 371 C
kernel32.dll!752133aa()
ntdll.dll!776d9ef2()
ntdll.dll!776d9ec5()
代码(下面的L是std :: deque(不是有很好理由的向量),以下函数将被重复调用超过200,000次):
SpringLink* ParticleSystem::createLink(Particle* p1_ptr,
Particle* p2_ptr, Material material)
{
bool isDirectlyLinked = this->isDirectNeighor(*p1_ptr, *p2_ptr);
// Create the Spring Link
SpringLink* springLinkPtr = new SpringLink(p1_ptr->getIdx(), p2_ptr->getIdx());
springLinkPtr->addMaterial(material);
springLinkPtr->isDiagonal = !isDirectlyLinked;
L.push_back(*springLinkPtr);
int linkIdx = L.size()-1;
L[linkIdx].setIdx(linkIdx);
// Fill in the 'neighorhood' info
p1_ptr->addNeigParticleIdx(p2_ptr->getIdx(), linkIdx);
p2_ptr->addNeigParticleIdx(p1_ptr->getIdx(), linkIdx);
// Create the link display - for drawing only
SpringLinkDisplay* springForcePtr = new SpringLinkDisplay(p1_ptr, p2_ptr);
//springForcePtr->k = springLinkPtr->k;
// For drawing different material using differet colors
springForcePtr->set_colorRGBA(springLinkPtr->get_colorRGBA());
// For drawing diagonal link using differet colors
springForcePtr->isDiagonal = !isDirectlyLinked;
S.push_back(*springForcePtr);
int forceIdx = S.size()-1;
S[forceIdx].setIdx(forceIdx);
return &(L[linkIdx]);
}
问题:
编辑:
我刚刚在我的任务管理器监视器中找到了可能有趣的内容
- Phycial Memory(MB) -
总计8183
缓存2599
可用2544
免费4
- 内核内存(MB) -
Paged 274
非分页250
- 问题: -