puts "===========" puts "BUC60921" puts "BUC60954" puts "===========" pload QAcommands # see end of script! #set EXEID TCAF set EXEID DRAWEXE set BREP [locate_data_file BUC60921.brep] NewDocument D MDTV-Standard UndoLimit D 100 set MemoryLeakage 0 set i_max 10 set IsFirstTime 1 for {set i 1} {$i <= ${i_max}} {incr i} { CommitCommand D OpenCommand D BUC60921 D 0:1:1 $BREP catch {exec ps -e -o vsz,comm | grep $EXEID } res puts "Iteration $i: virtual memory consumption = $res" set Mem1 [lindex ${res} 0] if { ${IsFirstTime} == 1} { set Mem0 ${Mem1} set IsFirstTime 0 } CommitCommand D OpenCommand D Undo D catch {exec ps -e -o vsz,comm | grep $EXEID } res puts "Iteration $i: virtual memory consumption = $res" set Mem2 [lindex ${res} 0] set Delta [expr abs(${Mem2} - ${Mem1})] set MemoryLeakage [expr ${MemoryLeakage} + ${Delta}] puts " ${i} delta memory consumed: ${Delta} KB" } set percent_max 5 set percent [expr ${MemoryLeakage} / (double(${i_max}) * ${Mem0} ) * 100.] puts "percent = ${percent}" if {${percent} > ${percent_max}} { puts "BUC60921: Error . There is memory leakage during Undo/Redo" } else { puts "BUC60921: OK" } # This TCL script demonstrates memory leak in OCAF Undo/Redo # # The DRAW command TestOCAF (provided separately) just reads # the specified brep file # and puts it into the document on a given label. # This operation is done and undone several times, # and the problem is that each time additional memory # (approximately equivalent to the size of shape) # is consumed. # # While obviously it should not be so: even if Undo keeps the # shape in memory as delta on Redo, this delta should be cleared # by the next operation! # # The bug persists with any setting of variables MMGT_OPT and MMGT_MMAP # (while with different initial size and step) and # # It seems that either delta is not completely freed, or some # other data structures keep the shape memory #================================================ # The two settings below are necessary to localize the script in order # to identify DRAW process among others, and to define path to BREP file # The BREP file should be big anough (>= 1Mb recommended) set EXEID QATCAF set BREP /users/det/files/GEAR.brep #================================================