1
0
Fork 0

Till Busch:

As discussed with Tim on irc: Here is a quick fix for the memory-hungry tile
manager. Due to bugs in FGNewCache, old tiles were never deleted.

I left the timestamp-updates in the cull-traversal. but imho things work
just as well when timestamps are updated in FGNewCache::insert_tile() and
FGNewCache::get_tile()
This commit is contained in:
curt 2008-02-21 21:36:20 +00:00
parent 2186fdf961
commit c3ee389fe0
3 changed files with 10 additions and 6 deletions

View file

@ -102,7 +102,7 @@ long FGNewCache::get_oldest_tile() {
// we need to free the furthest entry
long min_index = -1;
double timestamp = 0.0;
double max_time = 0;
double min_time = DBL_MAX;
tile_map_iterator current = tile_cache.begin();
tile_map_iterator end = tile_cache.end();
@ -113,8 +113,9 @@ long FGNewCache::get_oldest_tile() {
if ( e->is_loaded() ) {
timestamp = e->get_timestamp();
if ( timestamp > max_time ) {
max_time = timestamp;
if ( timestamp < min_time ) {
min_time = timestamp;
min_index = index;
}
} else {
@ -124,7 +125,7 @@ long FGNewCache::get_oldest_tile() {
}
SG_LOG( SG_TERRAIN, SG_DEBUG, " index = " << min_index );
SG_LOG( SG_TERRAIN, SG_DEBUG, " max_time = " << max_time );
SG_LOG( SG_TERRAIN, SG_DEBUG, " min_time = " << min_time );
return min_index;
}
@ -182,6 +183,8 @@ void FGNewCache::clear_cache() {
bool FGNewCache::insert_tile( FGTileEntry *e ) {
// register tile in the cache
long tile_index = e->get_tile_bucket().gen_index();
// not needed if timestamps are updated in cull-callback
// e->set_timestamp(globals->get_sim_time_sec());
tile_cache[tile_index] = e;
return true;

View file

@ -104,7 +104,8 @@ public:
inline FGTileEntry *get_tile( const long tile_index ) const {
const_tile_map_iterator it = tile_cache.find( tile_index );
if ( it != tile_cache.end() ) {
it->second->set_timestamp(globals->get_sim_time_sec());
// not needed if timestamps are updated in cull-callback
// it->second->set_timestamp(globals->get_sim_time_sec());
return it->second;
} else {
return NULL;

View file

@ -99,7 +99,7 @@ namespace
class TileCullCallback : public osg::NodeCallback
{
public:
TileCullCallback() : _timeStamp(DBL_MAX) {}
TileCullCallback() : _timeStamp(0) {}
TileCullCallback(const TileCullCallback& tc, const osg::CopyOp& copyOp) :
NodeCallback(tc, copyOp), _timeStamp(tc._timeStamp)
{