On Thu, Jun 10, 2010 at 10:33 PM, Noel O'Boyle <baoille...@gmail.com> wrote:
> On 10 June 2010 21:27, Tim Vandermeersch <tim.vandermeer...@gmail.com> wrote:
>> On Thu, Jun 10, 2010 at 10:22 PM, Noel O'Boyle <baoille...@gmail.com> wrote:
>>> Hi all,
>>>
>>> The built-in memory leak detection in MSVC2008 seems not to work (no
>>> line numbers), but I've found Visual Leak Detector to work amazingly
>>> well (given that I don't know what I'm doing):
>>> http://sites.google.com/site/dmoulding/vld
>>>
>>> Basically, I installed that and followed the simple instructions, and
>>> then added "include <vld.h>" to the top of obconversion.h, and then
>>> ran "babel" in Debug mode with an SDF to SDF conversion.
>>>
>>> Converting 5 files, there are 80 memory leaks. Then I found that one
>>> of the memory leaks was one of my first contributions to OpenBabel:
>>> _frag_atoms = new OBBitVec(_pmol->NumAtoms());. By adding a delete to
>>> the destructor I got down to 70 leaks.
>>>
>>> If anyone's interested in the log file I can provide it.
>>
>> Yes, I'd like to have a look. When I run in valgrind, I always detect
>> a few leaks when reading molecules. I don't know where they are coming
>> from but perhaps another tool might contain other information. Just
>> like some bugs, these detected leaks can be platform specific.
>
> Actually, it seems that all of the other leaks (I think) are
> associated with RegisterOptionParams. Maybe you could take a look.

Could you try the attached patch?

> See http://pastebin.com/q60k28nZ (unfortunately, due to the #include
> in obconversion, the line numbers will be one or two off).
>
> - Noel
>
>>> - Noel
>>>
>>> ------------------------------------------------------------------------------
>>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>>> lucky parental unit.  See the prize list and enter to win:
>>> http://p.sf.net/sfu/thinkgeek-promo
>>> _______________________________________________
>>> OpenBabel-Devel mailing list
>>> OpenBabel-Devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/openbabel-devel
>>>
>>
>
diff --git a/src/obconversion.cpp b/src/obconversion.cpp
index 3af688c..a562c4a 100644
--- a/src/obconversion.cpp
+++ b/src/obconversion.cpp
@@ -1432,7 +1432,8 @@ namespace OpenBabel {
 
   OBConversion::OPAMapType& OBConversion::OptionParamArray(Option_type typ)
   {
-    static OPAMapType* opa = new OPAMapType[3];
+    // Will be deleted when the program exits
+    static OPAMapType opa[3];
     return opa[typ];
   }
 
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to