]> gitweb.factorcode.org Git - factor.git/blob - core/memory/memory-tests.factor
Merge remote-tracking branch 'upstream/master'
[factor.git] / core / memory / memory-tests.factor
1 USING: accessors kernel kernel.private math memory prettyprint
2 io sequences tools.test words namespaces layouts classes
3 classes.builtin arrays quotations system ;
4 FROM: tools.memory => data-room code-room ;
5 IN: memory.tests
6
7 [ save-image-and-exit ] must-fail
8
9 ! Tests for 'instances'
10 [ [ ] instances ] must-infer
11 2 [ [ [ 3 throw ] instances ] must-fail ] times
12
13 ! Tests for 'become'
14 [ ] [ { } { } become ] unit-test
15
16 ! Bug found on Windows build box, having too many words in the
17 ! image breaks 'become'
18 [ ] [ 100000 [ f <uninterned-word> ] replicate { } { } become drop ] unit-test
19
20 ! Bug: code heap collection had to be done when data heap was
21 ! full, not just when code heap was full. If the code heap
22 ! contained dead code blocks referring to large data heap
23 ! objects, those large objects would continue to live on even
24 ! if the code blocks were not reachable, as long as the code
25 ! heap did not fill up.
26 : leak-step ( -- ) 800000 f <array> 1quotation call( -- obj ) drop ;
27
28 : leak-loop ( -- ) 100 [ leak-step ] times ;
29
30 [ ] [ leak-loop ] unit-test
31
32 ! Bug: allocation of large objects directly into tenured space
33 ! can proceed past the high water mark.
34 !
35 ! Suppose the nursery and aging spaces are mostly comprised of
36 ! reachable objects. When doing a full GC, objects from young
37 ! generations ere promoted *before* unreachable objects in
38 ! tenured space are freed by the sweep phase. So if large object
39 ! allocation filled up the heap past the high water mark, this
40 ! promotion might trigger heap growth, even if most of those
41 ! large objects are unreachable.
42 SYMBOL: foo
43
44 [ ] [
45     gc
46
47     data-room tenured>> size>>
48     
49     10 [
50         4 [ 120 1024 * f <array> ] replicate foo set-global
51         100 [ 256 1024 * f <array> drop ] times
52     ] times
53     
54     data-room tenured>> size>>
55     assert=
56 ] unit-test