mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-31 18:32:11 +00:00
added getTotalSharedMem et al.
This commit is contained in:
@@ -1434,6 +1434,20 @@ when not defined(nimrodVM) and hostOS != "standalone":
|
||||
proc getTotalMem*(): int {.rtl.}
|
||||
## returns the number of bytes that are owned by the process.
|
||||
|
||||
when hasThreadSupport:
|
||||
proc getOccupiedSharedMem*(): int {.rtl.}
|
||||
## returns the number of bytes that are owned by the process
|
||||
## on the shared heap and hold data. This is only available when
|
||||
## threads are enabled.
|
||||
|
||||
proc getFreeSharedMem*(): int {.rtl.}
|
||||
## returns the number of bytes that are owned by the
|
||||
## process on the shared heap, but do not hold any meaningful data.
|
||||
## This is only available when threads are enabled.
|
||||
|
||||
proc getTotalSharedMem*(): int {.rtl.}
|
||||
## returns the number of bytes on the shared heap that are owned by the
|
||||
## process. This is only available when threads are enabled.
|
||||
|
||||
iterator countdown*[T](a, b: T, step = 1): T {.inline.} =
|
||||
## Counts from ordinal value `a` down to `b` with the given
|
||||
|
||||
@@ -835,4 +835,20 @@ template instantiateForRegion(allocator: expr) =
|
||||
else:
|
||||
result = realloc(p, newsize)
|
||||
|
||||
when hasThreadSupport:
|
||||
|
||||
template sharedMemStatsShared(v: int) {.immediate.} =
|
||||
acquireSys(heapLock)
|
||||
result = v
|
||||
releaseSys(heapLock)
|
||||
|
||||
proc getFreeSharedMem(): int =
|
||||
sharedMemStatsShared(sharedHeap.freeMem)
|
||||
|
||||
proc getTotalSharedMem(): int =
|
||||
sharedMemStatsShared(sharedHeap.currMem)
|
||||
|
||||
proc getOccupiedSharedMem(): int =
|
||||
sharedMemStatsShared(sharedHeap.currMem - sharedHeap.freeMem)
|
||||
|
||||
{.pop.}
|
||||
|
||||
Reference in New Issue
Block a user