alloc.h 1017 B

1234567891011121314151617181920212223242526272829303132333435
  1. #pragma once
  2. #include <stddef.h>
  3. namespace NAllocSetup {
  4. void ThrowOnError(size_t allocSize);
  5. void SetThrowConditions(size_t currSize, size_t maxSize);
  6. void SetSoftLimit(size_t softLimit);
  7. void SetHardLimit(size_t hardLimit);
  8. void SetAllocationThreshold(size_t allocationThreshold);
  9. void SetSoftReclaimDivisor(size_t softReclaimDivisor);
  10. void SetAngryReclaimDivisor(size_t angryReclaimDivisor);
  11. bool CanAlloc(size_t allocSize, size_t totalAllocSize);
  12. bool NeedReclaim(size_t gcSize_, size_t counter);
  13. size_t GetTotalAllocSize();
  14. size_t GetCurSize();
  15. size_t GetGCSize();
  16. size_t GetSoftLimit();
  17. size_t GetHardLimit();
  18. size_t GetAllocationThreshold();
  19. size_t GetSoftReclaimDivisor();
  20. size_t GetAngryReclaimDivisor();
  21. bool IsEnabledByDefault();
  22. struct TAllocGuard {
  23. TAllocGuard(size_t maxSize) {
  24. SetThrowConditions(0, maxSize);
  25. }
  26. ~TAllocGuard() {
  27. SetThrowConditions(0, 0);
  28. }
  29. };
  30. }