Skip to content

Commit

Permalink
fixed memory leak (of textures) in map_display.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
hershwg committed Jun 28, 2013
1 parent d332f9a commit 4b031b6
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/rviz/default_plugin/map_display.cpp
Original file line number Diff line number Diff line change
@@ -429,9 +429,11 @@ void MapDisplay::clear()
manual_object_->setVisible( false );
}

std::string tex_name = texture_->getName();
texture_.setNull();
Ogre::TextureManager::getSingleton().unload( tex_name );
if( !texture_.isNull() )
{
Ogre::TextureManager::getSingleton().remove( texture_->getName() );
texture_.setNull();
}

loaded_ = false;
}
@@ -480,17 +482,6 @@ void MapDisplay::incomingUpdate(const map_msgs::OccupancyGridUpdate::ConstPtr& u
showMap();
}

// HardwarePixelBufferSharedPtr pixel_buffer = texture_->getBuffer();

// // Lock the pixel buffer and get a pixel box
// pixel_buffer->lock( HardwareBuffer::HBL_DISCARD );
// const PixelBox& pixel_box = pixel_buffer->getCurrentLock();

// uint8* pixels = static_cast<uint8*>( pixel_box.data );

// // Unlock the pixel buffer
// pixel_buffer->unlock();

void MapDisplay::showMap()
{
if (current_map_.data.empty())
@@ -564,6 +555,12 @@ void MapDisplay::showMap()
Ogre::DataStreamPtr pixel_stream;
pixel_stream.bind( new Ogre::MemoryDataStream( pixels, pixels_size ));

if( !texture_.isNull() )
{
Ogre::TextureManager::getSingleton().remove( texture_->getName() );
texture_.setNull();
}

static int tex_count = 0;
std::stringstream ss;
ss << "MapTexture" << tex_count++;

0 comments on commit 4b031b6

Please sign in to comment.