[lammps-users] std::bad_alloc

Hi. I did a run recently and it aborted after 295500 steps with the error message

terminate called after throwing an instance of 'std::bad_alloc'
   what(): St9bad_alloc

grep did not show any instances of "terminate" or "std::bad_alloc" in the LAMMPS code - was this message generated by the operating system? If so, is there any way (apart from using a debugger) to determine the source of the error? Using a debugger would take a long time since the error didn't occur until so deep in the run. Indeed, I find it odd that any error would take so long to show up.

Thanks,
Rob

hi,

Hi. I did a run recently and it aborted after 295500 steps with the
error message

terminate called after throwing an instance of 'std::bad_alloc'
   what(): St9bad_alloc

grep did not show any instances of "terminate" or "std::bad_alloc" in
the LAMMPS code - was this message generated by the operating system?

this should be a result from new/delete.

If so, is there any way (apart from using a debugger) to determine the

this looks like you may have a memory leak or some other process
competing for memory on the same machine. i would run a smaller and
shorter version of your input under valgrind. you can also monitor
with top how the virtual address space size changes.

source of the error? Using a debugger would take a long time since the
error didn't occur until so deep in the run. Indeed, I find it odd
that any error would take so long to show up.

if you have a small memory leak, it is not surprising. the big question
is: can you reproduce this error, i.e. if you restart from a frame
that close to the crash, does it still crash. or if you redo the whole
run, does it crash at the same point.

cheers,
   axel.

I agree w/ everything Alex said. I don't know of any such memory
leaks in LAMMPS, but there could always be one. Rob, if
you added your own stuff to LAMMPS, that is where I'd look
first. Valgrind could help you find it quickly.

Steve

Thanks, Axel and Steve! The error was indeed in my modifications to the code.

Best,
Rob