Memory Leak Fix - SGMaterial

Reclaimed 61,560 bytes in 405 blocks
This commit is contained in:
Scott Giese
2020-08-24 00:20:26 -05:00
parent e1e70e8d33
commit f14bcfb3c5
2 changed files with 9 additions and 9 deletions
+2 -3
View File
@@ -96,7 +96,7 @@ void SGMaterial::_internal_state::add_texture(const std::string &t, int i)
SGMaterial::SGMaterial( const SGReaderWriterOptions* options, SGMaterial::SGMaterial( const SGReaderWriterOptions* options,
const SGPropertyNode *props, const SGPropertyNode *props,
SGPropertyNode *prop_root, SGPropertyNode *prop_root,
AreaList *a, std::shared_ptr<AreaList> a,
SGSharedPtr<const SGCondition> c) SGSharedPtr<const SGCondition> c)
{ {
init(); init();
@@ -109,7 +109,7 @@ SGMaterial::SGMaterial( const SGReaderWriterOptions* options,
SGMaterial::SGMaterial( const osgDB::Options* options, SGMaterial::SGMaterial( const osgDB::Options* options,
const SGPropertyNode *props, const SGPropertyNode *props,
SGPropertyNode *prop_root, SGPropertyNode *prop_root,
AreaList *a, std::shared_ptr<AreaList> a,
SGSharedPtr<const SGCondition> c) SGSharedPtr<const SGCondition> c)
{ {
osg::ref_ptr<SGReaderWriterOptions> opt; osg::ref_ptr<SGReaderWriterOptions> opt;
@@ -412,7 +412,6 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
if (props->hasChild("parameters")) { if (props->hasChild("parameters")) {
parameters = props->getChild("parameters"); parameters = props->getChild("parameters");
} else { } else {
// REVIEW: Memory Leak - 61,560 bytes in 405 blocks are definitely lost
parameters = new SGPropertyNode(); parameters = new SGPropertyNode();
} }
} }
+7 -6
View File
@@ -31,6 +31,7 @@
#include <string> // Standard C++ string library #include <string> // Standard C++ string library
#include <vector> #include <vector>
#include <map> #include <map>
#include <memory>
#include <mutex> #include <mutex>
#include "Effect.hxx" #include "Effect.hxx"
@@ -96,15 +97,15 @@ public:
SGMaterial(const osgDB::Options*, SGMaterial(const osgDB::Options*,
const SGPropertyNode *props, const SGPropertyNode *props,
SGPropertyNode *prop_root, SGPropertyNode *prop_root,
AreaList *a, std::shared_ptr<AreaList> a,
SGSharedPtr<const SGCondition> c); SGSharedPtr<const SGCondition> c);
SGMaterial(const simgear::SGReaderWriterOptions*, SGMaterial(const simgear::SGReaderWriterOptions*,
const SGPropertyNode *props, const SGPropertyNode *props,
SGPropertyNode *prop_root, SGPropertyNode *prop_root,
AreaList *a, std::shared_ptr<AreaList> a,
SGSharedPtr<const SGCondition> c); SGSharedPtr<const SGCondition> c);
/** /**
* Destructor. * Destructor.
@@ -512,10 +513,10 @@ private:
SGSharedPtr<const SGCondition> condition; SGSharedPtr<const SGCondition> condition;
// List of geographical rectangles for this material // List of geographical rectangles for this material
AreaList* areas; std::shared_ptr<AreaList> areas;
// Parameters from the materials file // Parameters from the materials file
const SGPropertyNode* parameters; SGConstPropertyNode_ptr parameters;
// per-material lock for entrypoints called from multiple threads // per-material lock for entrypoints called from multiple threads
std::mutex _lock; std::mutex _lock;