[lammps-users] Memory leak when using AIREBO pair style with write_restart

Dear All,

I have recently noticed a problem with the AIREBO pair style in LAMMPS which causes memory to be leaked if the write_restart and displace_atom commands (and possibly others) are used in the input script in conjunction with the AIREBO pair style.

Using valgrind on the serial version of lammps (version 16Sep10), the problem can be traced to init_style() in pair_airebo.cpp (see the valgrind output posted at the end of the message).

This behaviour becomes problematic when write_restart is called several times (e.g. inside a loop), and eventually causes the system to run out of memory.

A straightforward change to init_style() seems to fix the problem:

$ diff -u pair_airebo.cpp.orig pair_airebo.cpp
--- pair_airebo.cpp.orig 2010-09-17 12:03:04.481466000 +0100
+++ pair_airebo.cpp 2010-09-17 12:05:07.028561000 +0100
@@ -220,7 +220,7 @@

   pgsize = neighbor->pgsize;
   oneatom = neighbor->oneatom;
- if (maxlocal == 0) add_pages(0);
+ if (maxpage == 0) add_pages(0);

I'd be interested to know if anyone has any opinions on this and if this should be reported as a bug in LAMMPS.

Kind regards,
Ruairi Nestor

Dr. Ruairi Nestor

Any memory leak is a bug - I'll take a look.