summary refs log tree commit diff stats
path: root/tests/fragmentation/tfragment_alloc.nim
blob: 5a44b7434d3b87f7c066aa863c3057acfb576d7e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
discard """
  output: '''occupied ok: true
total ok: true'''
"""

import strutils, data

proc main =
  var m = 0
  for i in 0..1000_000:
    let size = sizes[i mod sizes.len]
    let p = alloc(size)
    if p == nil:
      quit "could not serve request!"
    dealloc p
 #   c_fprintf(stdout, "iteration: %ld size: %ld\n", i, size)
  when defined(cpu64):
    # bug #7120
    var x = alloc(((1 shl 29) - 4) * 8)
    dealloc x

main()

let occ = getOccupiedMem()
let total = getTotalMem()

# Current values on Win64: 824KiB / 106.191MiB

echo "occupied ok: ", occ < 2 * 1024 * 1024
echo "total ok: ", total < 120 * 1024 * 1024