MCPcopy Create free account
hub / github.com/InternScience/InternAgent / clear_memory_cache

Function clear_memory_cache

internagent/mas/tools/memory_retrieval.py:614–630  ·  view source on GitHub ↗

Clear cached memory instances and free GPU memory

()

Source from the content-addressed store, hash-verified

612
613
614def clear_memory_cache():
615 """Clear cached memory instances and free GPU memory"""
616 global _memory_cache
617
618 num_entries = len(_memory_cache)
619 _memory_cache.clear()
620
621 # Clear PyTorch GPU cache
622 try:
623 import torch
624 if torch.cuda.is_available():
625 torch.cuda.empty_cache()
626 logger.info(f"Cleared memory cache ({num_entries} entries) and GPU cache")
627 else:
628 logger.info(f"Cleared memory cache ({num_entries} entries)")
629 except ImportError:
630 logger.info(f"Cleared memory cache ({num_entries} entries)")

Callers 1

mainFunction · 0.90

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected