diff --git a/Source/Engine/Content/Storage/ContentStorageManager.cpp b/Source/Engine/Content/Storage/ContentStorageManager.cpp index 80744ae45..8aa36c7be 100644 --- a/Source/Engine/Content/Storage/ContentStorageManager.cpp +++ b/Source/Engine/Content/Storage/ContentStorageManager.cpp @@ -46,6 +46,7 @@ namespace ContentStorageService ContentStorageServiceInstance; +TimeSpan ContentStorageManager::UnusedStorageLifetime = TimeSpan::FromSeconds(0.5f); TimeSpan ContentStorageManager::UnusedDataChunksLifetime = TimeSpan::FromSeconds(10); FlaxStorageReference ContentStorageManager::GetStorage(const StringView& path, bool loadIt) diff --git a/Source/Engine/Content/Storage/ContentStorageManager.h b/Source/Engine/Content/Storage/ContentStorageManager.h index 0d56855ea..fac27aa7f 100644 --- a/Source/Engine/Content/Storage/ContentStorageManager.h +++ b/Source/Engine/Content/Storage/ContentStorageManager.h @@ -15,7 +15,12 @@ class FLAXENGINE_API ContentStorageManager { public: /// - /// Auto-release timeout for unused asset chunks. + /// Auto-release timeout for unused asset files. + /// + static TimeSpan UnusedStorageLifetime; + + /// + /// Auto-release timeout for unused asset data chunks. /// static TimeSpan UnusedDataChunksLifetime; diff --git a/Source/Engine/Content/Storage/FlaxStorage.cpp b/Source/Engine/Content/Storage/FlaxStorage.cpp index 6967bb5ad..e286ee326 100644 --- a/Source/Engine/Content/Storage/FlaxStorage.cpp +++ b/Source/Engine/Content/Storage/FlaxStorage.cpp @@ -286,14 +286,14 @@ FlaxStorage::LockData FlaxStorage::LockSafe() uint32 FlaxStorage::GetRefCount() const { - return (uint32)Platform::AtomicRead((int64*)&_refCount); + return (uint32)Platform::AtomicRead(&_refCount); } bool FlaxStorage::ShouldDispose() const { - return Platform::AtomicRead((int64*)&_refCount) == 0 && - Platform::AtomicRead((int64*)&_chunksLock) == 0 && - Platform::GetTimeSeconds() - _lastRefLostTime >= 0.5; // TTL in seconds + return Platform::AtomicRead(&_refCount) == 0 && + Platform::AtomicRead(&_chunksLock) == 0 && + Platform::GetTimeSeconds() - _lastRefLostTime >= ContentStorageManager::UnusedStorageLifetime.GetTotalSeconds(); } uint32 FlaxStorage::GetMemoryUsage() const