Debugging strategy to find the cause of bad_alloc

前端 未结 6 736
Happy的楠姐
Happy的楠姐 2021-01-30 13:04

I have a fairly serious bug in my program - occasional calls to new() throw a bad_alloc.

From the documentation I can find on bad_alloc, it seems to be thrown for these

6条回答
  •  后悔当初
    2021-01-30 13:55

    Another possible problem is that, while you mention that the program is using less than 5MB, you don't mention how much space it's trying to allocate. You could have some race condition that's corrupting the value that you use to determine the allocation size, and it could be trying to allocate 37TB or somesuch nonsense.

    Not particularly likely, I suppose, but worth checking.

提交回复
热议问题