Skip to content

Commit

Permalink
force cleanup is RAM is filled more than 95%
Browse files Browse the repository at this point in the history
  • Loading branch information
activesoull committed Apr 27, 2024
1 parent 2f3267d commit 3d80cfe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion deeplake/core/storage/lru_cache.py
Expand Up @@ -4,6 +4,7 @@
from deeplake.core.storage.deeplake_memory_object import DeepLakeMemoryObject
from deeplake.core.chunk.base_chunk import BaseChunk
from typing import Any, Dict, Optional, Union
import psutil

from deeplake.core.storage.provider import StorageProvider
import time
Expand Down Expand Up @@ -415,7 +416,10 @@ def _free_up_space(self, extra_size: int):
Args:
extra_size (int): the space that needs is required in bytes.
"""
while self.cache_used > 0 and extra_size + self.cache_used > self.cache_size:
while self.cache_used > 0 and (
extra_size + self.cache_used > self.cache_size
or psutil.virtual_memory().percent > 95
):
self._pop_from_cache()

def _pop_from_cache(self):
Expand Down
1 change: 1 addition & 0 deletions deeplake/requirements/common.txt
Expand Up @@ -24,3 +24,4 @@ azure-cli
azure-identity
azure-storage-blob
pydantic
psutil

0 comments on commit 3d80cfe

Please sign in to comment.