diff --git a/src/CacheMemory.cpp b/src/CacheMemory.cpp index 52e3a313..8170c2c0 100644 --- a/src/CacheMemory.cpp +++ b/src/CacheMemory.cpp @@ -310,12 +310,14 @@ long int CacheMemory::Count() void CacheMemory::CleanUp() { cout << "CacheMemory::CleanUp" << endl; - // Create a scoped lock, to protect the cache from multiple threads - const GenericScopedLock lock(*cacheCriticalSection); + cout << " -- max_bytes: " << max_bytes << endl; // Do we auto clean up? if (max_bytes > 0) { + // Create a scoped lock, to protect the cache from multiple threads + const GenericScopedLock lock(*cacheCriticalSection); + while (GetBytes() > max_bytes && frame_numbers.size() > 20) { // Get the oldest frame number. diff --git a/tests/Cache_Tests.cpp b/tests/Cache_Tests.cpp index f8f9b1ca..f3ac1eb7 100644 --- a/tests/Cache_Tests.cpp +++ b/tests/Cache_Tests.cpp @@ -47,11 +47,8 @@ TEST(Cache_Default_Constructor) c.Add(f); } - cout << "Cache_Default_Constructor A" << endl; CHECK_EQUAL(50, c.Count()); // Cache should have all frames, with no limit - cout << "Cache_Default_Constructor B" << endl; CHECK_EQUAL(0, c.GetMaxBytes()); // Max frames should default to 0 - cout << "Cache_Default_Constructor C" << endl; } TEST(Cache_Max_Bytes_Constructor)