Corrections for tests after integration of 2012-12-07
[occt.git] / tests / bugs / caf / buc60921
1 puts "==========="
2 puts "BUC60921"
3 puts "BUC60954"
4 puts "==========="
5
6 pload QAcommands
7
8 # see end of script!
9 #set EXEID TCAF
10 set EXEID DRAWEXE
11 set BREP [locate_data_file BUC60921.brep]
12
13 NewDocument D MDTV-Standard
14 UndoLimit D 100
15
16 set MemoryLeakage 0
17 set i_max 10
18 set IsFirstTime 1
19 for {set i 1} {$i <= ${i_max}} {incr i} {
20     CommitCommand D
21     OpenCommand D
22     BUC60921 D 0:1:1 $BREP
23
24     catch {exec ps -e -o vsz,comm | grep $EXEID } res
25     puts "Iteration $i: virtual memory consumption = $res"
26     set Mem1 [lindex ${res} 0]
27     if { ${IsFirstTime} == 1} {
28         set Mem0 ${Mem1}
29         set IsFirstTime 0
30     }
31     CommitCommand D
32     OpenCommand D
33     Undo D
34     catch {exec ps -e -o vsz,comm | grep $EXEID } res
35     puts "Iteration $i: virtual memory consumption = $res"
36     set Mem2 [lindex ${res} 0]
37     set Delta [expr abs(${Mem2} - ${Mem1})]
38     set MemoryLeakage [expr ${MemoryLeakage} + ${Delta}]
39     puts "       ${i} delta memory consumed: ${Delta} KB"
40 }
41
42 set percent_max 5
43 set percent [expr ${MemoryLeakage} / (double(${i_max}) * ${Mem0} ) * 100.]
44 puts "percent = ${percent}"
45
46 if {${percent} > ${percent_max}} {
47    puts "BUC60921: Error . There is memory leakage during Undo/Redo"
48 } else {
49    puts "BUC60921: OK"
50 }
51
52
53 # This TCL script demonstrates memory leak in OCAF Undo/Redo
54 #
55 # The DRAW command TestOCAF (provided separately) just reads 
56 # the specified brep file
57 # and puts it into the document on a given label.
58 # This operation is done and undone several times,
59 # and the problem is that each time additional memory
60 # (approximately equivalent to the size of shape)
61 # is consumed.
62 #
63 # While obviously it should not be so: even if Undo keeps the 
64 # shape in memory as delta on Redo, this delta should be cleared 
65 # by the next operation!
66 #
67 # The bug persists with any setting of variables MMGT_OPT and MMGT_MMAP
68 # (while with different initial size and step) and 
69 #
70 # It seems that either delta is not completely freed, or some
71 # other data structures keep the shape memory
72
73 #================================================
74 # The two settings below are necessary to localize the script in order
75 # to identify DRAW process among others, and to define path to BREP file
76 # The BREP file should be big anough (>= 1Mb recommended)
77 set EXEID QATCAF
78 set BREP /users/det/files/GEAR.brep
79 #================================================