-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathjava_heap.py
More file actions
36 lines (26 loc) · 1.08 KB
/
java_heap.py
File metadata and controls
36 lines (26 loc) · 1.08 KB
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
32
33
34
35
36
"""
Test scyjava JVM memory-related functions.
"""
import scyjava
from assertpy import assert_that
mb_initial = 50 # initial MB of memory to snarf up
mb_tolerance = 10 # ceiling of expected MB in use
scyjava.config.set_heap_min(mb=mb_initial)
scyjava.config.set_heap_max(gb=1)
assert_that(scyjava.jvm_started()).is_false()
scyjava.start_jvm()
assert_that(scyjava.available_processors()).is_greater_than_or_equal_to(1)
mb_max = scyjava.memory_max() // 1024 // 1024
mb_total = scyjava.memory_total() // 1024 // 1024
mb_used = scyjava.memory_used() // 1024 // 1024
assert_that(
mb_used, "Used memory should be less than the current memory total"
).is_less_than_or_equal_to(mb_total)
assert_that(
mb_total, "current memory total should be less than maximum memory"
).is_less_than_or_equal_to(mb_max)
assert_that(mb_max, "maximum heap size should be approx. 1 GB").is_between(900, 1024)
assert_that(mb_used, "most memory should be available").is_less_than(mb_tolerance)
assert_that(mb_total, "total memory should be close to initial").is_close_to(
mb_initial, tolerance=mb_tolerance
)