]> git.mxchange.org Git - flightgear.git/commitdiff
Working on hunting down a really awful memory leak. This arose out of a
authorcurt <curt>
Tue, 6 Aug 2002 18:50:12 +0000 (18:50 +0000)
committercurt <curt>
Tue, 6 Aug 2002 18:50:12 +0000 (18:50 +0000)
misunderstanding over which section of code would be freeing tiles.  This
patch cleans up several things, but a little more work is still needed.

src/Scenery/newcache.cxx
src/Scenery/newcache.hxx
src/Scenery/tileentry.cxx

index f9c46b20ad9da3aa27ccf9be8e8878738907ae3f..4da87508d8b6e944eb493159e3cfbb9bd3aa3b75 100644 (file)
@@ -105,6 +105,7 @@ bool FGNewCache::exists( const SGBucket& b ) const {
 }
 
 
+#if 0
 // Ensure at least one entry is free in the cache
 bool FGNewCache::make_space() {
     SG_LOG( SG_TERRAIN, SG_DEBUG, "Make space in cache" );
@@ -169,6 +170,7 @@ bool FGNewCache::make_space() {
             "FGNewCache::make_space()." );
     return false;
 }
+#endif
 
 
 // Return the index of the oldest tile in the cache, return -1 if
@@ -246,18 +248,12 @@ void FGNewCache::clear_cache() {
 bool FGNewCache::insert_tile( FGTileEntry *e ) {
     // set time of insertion for tracking age of tiles...
     e->set_timestamp(globals->get_sim_time_sec());
-    // clear out a distant entry in the cache if needed.
-    if ( make_space() ) {
-        // register it in the cache
-        long tile_index = e->get_tile_bucket().gen_index();
-        tile_cache[tile_index] = e;
 
-        return true;
-    } else {
-        // failed to find cache space
+    // register it in the cache
+    long tile_index = e->get_tile_bucket().gen_index();
+    tile_cache[tile_index] = e;
 
-        return false;
-    }
+    return true;
 }
 
 
index 8060a1becea9dfe8b2978cd779d4bd55c0aa3b21..10686641afd400dd5fd5b801ee5f29e8e98b6048 100644 (file)
@@ -82,8 +82,10 @@ public:
     // Check if the specified "bucket" exists in the cache
     bool exists( const SGBucket& b ) const;
 
+#if 0
     // Ensure at least one entry is free in the cache
     bool make_space();
+#endif
 
     // Return the index of the oldest tile in the cache, return -1 if
     // nothing available to be removed.
index 8aae404f709f24985fa914ee1ca31d4b0f2ac756..428facd1981ed1867f92cdc9cfca05affa6aa7a1 100644 (file)
@@ -698,21 +698,17 @@ static int fgPartialFreeSSGtree( ssgBranch *b, int n ) {
                 int result = fgPartialFreeSSGtree( (ssgBranch *)kid, n );
                 num_deletes += result;
                 n -= result;
-                if ( kid->getNumKids() == 0 ) {
-                    b->removeKid(i);
-                    num_deletes++;
-                    n--;
-                }
                 if ( n < 0 ) {
                     break;
                 }
             } else {
                 b->removeKid(i);
                 num_deletes++;
+                n--;
             }
         }
         // remove the parent if it is empty
-        if ( b->getNumKids() < 0 ) {
+        if ( b->getNumKids() == 0 ) {
             ssgDeRefDelete( b );
             num_deletes++;
             n--;
@@ -731,6 +727,8 @@ bool FGTileEntry::free_tile() {
     SG_LOG( SG_TERRAIN, SG_DEBUG,
            "FREEING TILE = (" << tile_bucket << ")" );
 
+    SG_LOG( SG_TERRAIN, SG_DEBUG, "(start) free_tracker = " << free_tracker );
+    
     if ( !(free_tracker & NODES) ) {
         SG_LOG( SG_TERRAIN, SG_DEBUG,
                 "  deleting " << nodes.size() << " nodes" );
@@ -792,6 +790,8 @@ bool FGTileEntry::free_tile() {
         return true;
     }
 
+    SG_LOG( SG_TERRAIN, SG_DEBUG, "(end) free_tracker = " << free_tracker );
+
     // if we fall down to here, we still have work todo, return false
     return false;
 }