From Ryan Kawicki, added removal of TXPArchive from ReaderWriterTXP when the TXPNode destructs to fix memory consumption issue relating to leaving unused archives in memory.
This commit is contained in:
@@ -624,6 +624,12 @@ TXPArchive *ReaderWriterTXP::getArchive(int id, const std::string& dir)
|
||||
return archive;
|
||||
}
|
||||
|
||||
bool ReaderWriterTXP::removeArchive( int id )
|
||||
{
|
||||
osg::notify(osg::INFO)<<"ReaderWriterTXP::removeArchive(id="<<id<<")"<<std::endl;
|
||||
return (_archives.erase(id) >= 1);
|
||||
}
|
||||
|
||||
class SeamFinder: public osg::NodeVisitor
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -73,6 +73,8 @@ public:
|
||||
|
||||
return const_cast<ReaderWriterTXP*>(this)->local_readNode(file, options);
|
||||
}
|
||||
|
||||
bool removeArchive( int id );
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <osg/Timer>
|
||||
#include <osg/MatrixTransform>
|
||||
#include <osgUtil/CullVisitor>
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReaderWriter>
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
@@ -13,7 +15,7 @@
|
||||
#include "TileMapper.h"
|
||||
#include "TXPNode.h"
|
||||
#include "TXPPagedLOD.h"
|
||||
|
||||
#include "ReaderWriterTXP.h"
|
||||
|
||||
|
||||
using namespace txp;
|
||||
@@ -78,6 +80,22 @@ _originY(txpNode._originY)
|
||||
|
||||
TXPNode::~TXPNode()
|
||||
{
|
||||
if (_archive.get())
|
||||
{
|
||||
if (osgDB::ReaderWriter * rw =
|
||||
osgDB::Registry::instance()->getReaderWriterForExtension("txp"))
|
||||
{
|
||||
if (ReaderWriterTXP * rwTXP =
|
||||
dynamic_cast< ReaderWriterTXP * >(rw))
|
||||
{
|
||||
const int id = _archive->getId();
|
||||
if (!rwTXP->removeArchive(id))
|
||||
{
|
||||
TXPNodeERROR("Failed to remove archive ") << id << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TXPArchive* TXPNode::getArchive()
|
||||
|
||||
Reference in New Issue
Block a user