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

View File

@@ -96,7 +96,7 @@ void SGMaterial::_internal_state::add_texture(const std::string &t, int i)
SGMaterial::SGMaterial( const SGReaderWriterOptions* options,
const SGPropertyNode *props,
SGPropertyNode *prop_root,
AreaList *a,
std::shared_ptr<AreaList> a,
SGSharedPtr<const SGCondition> c)
{
init();
@@ -109,7 +109,7 @@ SGMaterial::SGMaterial( const SGReaderWriterOptions* options,
SGMaterial::SGMaterial( const osgDB::Options* options,
const SGPropertyNode *props,
SGPropertyNode *prop_root,
AreaList *a,
std::shared_ptr<AreaList> a,
SGSharedPtr<const SGCondition> c)
{
osg::ref_ptr<SGReaderWriterOptions> opt;
@@ -412,7 +412,6 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
if (props->hasChild("parameters")) {
parameters = props->getChild("parameters");
} else {
// REVIEW: Memory Leak - 61,560 bytes in 405 blocks are definitely lost
parameters = new SGPropertyNode();
}
}

View File

@@ -31,6 +31,7 @@
#include <string> // Standard C++ string library
#include <vector>
#include <map>
#include <memory>
#include <mutex>
#include "Effect.hxx"
@@ -96,15 +97,15 @@ public:
SGMaterial(const osgDB::Options*,
const SGPropertyNode *props,
SGPropertyNode *prop_root,
AreaList *a,
SGSharedPtr<const SGCondition> c);
std::shared_ptr<AreaList> a,
SGSharedPtr<const SGCondition> c);
SGMaterial(const simgear::SGReaderWriterOptions*,
const SGPropertyNode *props,
SGPropertyNode *prop_root,
AreaList *a,
SGSharedPtr<const SGCondition> c);
std::shared_ptr<AreaList> a,
SGSharedPtr<const SGCondition> c);
/**
* Destructor.
@@ -512,10 +513,10 @@ private:
SGSharedPtr<const SGCondition> condition;
// List of geographical rectangles for this material
AreaList* areas;
std::shared_ptr<AreaList> areas;
// Parameters from the materials file
const SGPropertyNode* parameters;
SGConstPropertyNode_ptr parameters;
// per-material lock for entrypoints called from multiple threads
std::mutex _lock;