From: Axel Kohlmeyer (
Date: Mon Jun 15 2009 - 10:00:02 CDT

On Mon, 2009-06-15 at 11:06 +0200, kumar prashanth wrote:
> I am working with a trajectory of around 150 frames of a bilayer lipid
> system. The script intends the following.
> Makes a fitting of a lipid molecule to some reference lipid and gets
> the atom coordinates of some atoms,which gets printed out.
> And this fitting scheme is generalized over a region by the selection
> "lipid within --- of protein" using a for loop.
> I have tried running the script and it crashes after working for a
> short time.
> and it gives a std::bad alloc message.
> I guess the problem is with the memory allocation. COuld anyone
> suggest a solution..


most likely you have a memory leak in your script.
this usually happens if you have unbalanced atom selections
in your script. this is impossible to tell without seeing
the script code.

if you want to try fixing it yourself, you can use the
attached vmd/tcl code, which i wrote for that purpose.

just uncompress and save it to the directory where you run
your script. the type at the vmd command prompt:

play debug_atomselect.tcl
debug_atomselect verbose
debug_atomselect on
debug_atomselect on ; # only needed if you get an error message about
command 0-9 not found

and then run your script

it should print updated statistics whenever a new selection
is created or deleted and help you to track down which part
of your code is wrong.


> Probably,freeing some memory space could be one. PLease let me know
> about this..

Axel Kohlmeyer
   Center for Molecular Modeling   --   University of Pennsylvania
Department of Chemistry, 231 S.34th Street, Philadelphia, PA 19104-6323
tel: 1-215-898-1582,  fax: 1-215-573-6233,  office-tel: 1-215-898-5425
If you make something idiot-proof, the universe creates a better idiot.