Skip to content

Commit

Permalink
Merged from svn/trunk changset 12654. Fixed memory growth issue when …
Browse files Browse the repository at this point in the history
…using Texture2D::SubloadCallbacks that don't set the TextureObjects sizes.
  • Loading branch information
robertosfield committed Jun 25, 2011
1 parent 8ea9d68 commit a92241d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/osg/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ void Texture::TextureObjectSet::flushDeletedTextureObjects(double currentTime, d
}
}

if (_parent->getCurrTexturePoolSize()<=_parent->getMaxTexturePoolSize())
if (_profile._size!=0 && _parent->getCurrTexturePoolSize()<=_parent->getMaxTexturePoolSize())
{
// OSG_NOTICE<<"Plenty of space in TextureObject pool"<<std::endl;
return;
Expand All @@ -431,7 +431,11 @@ void Texture::TextureObjectSet::flushDeletedTextureObjects(double currentTime, d

unsigned int numDeleted = 0;
unsigned int sizeRequired = _parent->getCurrTexturePoolSize() - _parent->getMaxTexturePoolSize();
unsigned int maxNumObjectsToDelete = static_cast<unsigned int>(ceil(double(sizeRequired) / double(_profile._size)));

unsigned int maxNumObjectsToDelete = _profile._size!=0 ?
static_cast<unsigned int>(ceil(double(sizeRequired) / double(_profile._size))):
_orphanedTextureObjects.size();

OSG_INFO<<"_parent->getCurrTexturePoolSize()="<<_parent->getCurrTexturePoolSize() <<" _parent->getMaxTexturePoolSize()="<< _parent->getMaxTexturePoolSize()<<std::endl;
OSG_INFO<<"Looking to reclaim "<<sizeRequired<<", going to look to remove "<<maxNumObjectsToDelete<<" from "<<_orphanedTextureObjects.size()<<" orhpans"<<std::endl;

Expand Down

0 comments on commit a92241d

Please sign in to comment.