hkmoffat / cantera

Automatically exported from code.google.com/p/cantera
0 stars 0 forks source link

XML_Node not cleaning up after itself? #126

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following is with g++ 4.6.3, Cantera 2.0.0 release, valgrind 3.6.0 on Linux.

If I feed a simple program to valgrind that merely instantiates an IdealGasMix 
object and then exits, I get many error messages from valgrind of the form:

==26343==    at 0x4A07C8E: operator new(unsigned long) (vg_replace_malloc.c:261)
==26343==    by 0x150EE638: std::string::_Rep::_S_create(unsigned long, 
unsigned long, std::allocator<char> const&) (new_allocator.h:92)
==26343==    by 0x150EFE64: char* std::string::_S_construct<char*>(char*, 
char*, std::allocator<char> const&, std::forward_iterator_tag) 
(basic_string.tcc:140)
==26343==    by 0x150EFFC4: std::basic_string<char, std::char_traits<char>, 
std::allocator<char> >::basic_string(std::string const&, unsigned long, 
unsigned long) (basic_string.h:1692)
==26343==    by 0x150EFFF1: std::string::substr(unsigned long, unsigned long) 
const (basic_string.h:2157)
==26343==    by 0x15FA7151: Cantera::stripws(std::string const&) (in 
/org/centers/pecos/new_modules/libraries/cantera/cantera-2.0.0/sl6/gcc-4.6/lib/l
ibcantera_shared.so)
==26343==    by 0x15FAA1A5: Cantera::XML_Reader::readValue() (in 
/org/centers/pecos/new_modules/libraries/cantera/cantera-2.0.0/sl6/gcc-4.6/lib/l
ibcantera_shared.so)
==26343==    by 0x15FAD01F: Cantera::XML_Node::build(std::istream&) (in 
/org/centers/pecos/new_modules/libraries/cantera/cantera-2.0.0/sl6/gcc-4.6/lib/l
ibcantera_shared.so)
==26343==    by 0x15F88C6D: Cantera::Application::get_XML_File(std::string, 
int) (in 
/org/centers/pecos/new_modules/libraries/cantera/cantera-2.0.0/sl6/gcc-4.6/lib/l
ibcantera_shared.so)
==26343==    by 0x15F9F62B: Cantera::get_XML_File(std::string, int) (in 
/org/centers/pecos/new_modules/libraries/cantera/cantera-2.0.0/sl6/gcc-4.6/lib/l
ibcantera_shared.so)
==26343==    by 0x40FB87: Cantera::IdealGasMix::IdealGasMix(std::string, 
std::string) (IdealGasMix.h:25)

This is not a big deal because I'm only working with one instantiation, but 
this is dirty and clutters up otherwise clean valgrind output.

Does anyone else see this? I won't have time to track this down for a couple of 
weeks, but someone feel free to beat me to it.

Original issue reported on code.google.com by ptbau...@gmail.com on 10 Nov 2012 at 1:19

GoogleCodeExporter commented 9 years ago
I think this is a result of fact that Cantera caches parsed XML documents in a 
static instance of the Application class. See Application::get_XML_File and the 
way the "xmlfiles" member variable is used. You can clear this cache with the 
function "Cantera::appdelete()" defined in global.h. After doing that, I get a 
clean report from "valgrind --leak-check=full".

Original comment by yarmond on 10 Nov 2012 at 4:02

GoogleCodeExporter commented 9 years ago

Original comment by yarmond on 22 Jan 2013 at 8:38