From: Peter Freddolino (
Date: Thu Jan 21 2021 - 00:33:44 CST

Dear Timothy,
Thanks for bringing this up. Indeed, there does seem to be a memory leak in
that part of the code. I would think it would be cleaner just to keep the
code basically as is, but create, use, and delete the atom selection. I'll
talk to the vmd core folks about getting this change made.
For your purposes, I would think the best solution is just to generate a
patch file and include it as supplementary material for your paper; you can
tell people that they can reproduce your setup by applying that patch to
the cgtools.tcl code in vmd 1.9.3, and that way you don't have to
distribute any of the rest of the code. Not sure if John or other current
folks on the dev team have other thoughts.

On Wed, Jan 20, 2021 at 2:09 PM Timothy Leong <> wrote:

> Greetings all,
> I recently had a crash that returned no error message when assigning LJ
> Parameters to a CG system with ~52000 atoms in the all-atom model on a
> Linux OS with 6 GB of RAM (VMD version 1.9.3). After looking into the
> cgtools.tcl package I noticed that lines 834-841 were responsible for the
> memory overflow issue, given that they involve the creation of numerous
> atomselections that accumulate without deletion. After commenting out that
> section and using the following as a replacement:
> set beta_list [[atomselect $pdbrefID all] get beta]
> set NCG 0
> # jdex is for debugging purposes
> # set jdex -1
> foreach {beta_val} $beta_list {
> # incr jdex
> if {$beta_val > $NCG} {
> set NCG $beta_val
> }
> # puts $jdex
> }
> unset beta_list
> # There should not be any adverse effects from leaving the integer
> conversion
> # until the very end. The benefit of this is decreased computational load.
> set NCG [expr int($NCG)]
> ...the LJ parameter assignment works without crashing VMD. However, I want
> to know if it is possible to implement this change without 'hard-coding'
> the original cgtools.tcl package.
> The reason for this is because my patch is going to be included as part of
> my Principal Investigator's upcoming research paper, and that cgtools.tcl
> is the copyright of Axel Kohlmeyer. As a result, I obviously would not like
> to have to copy the rest of the ::cgtools::sasa_LJ_networking procedure if
> I can avoid it.
> Sincerely,
> Timothy Leong