**Memory error** System exception (crazy RAM usage) Maxscript -
i getting memory error , have been unable fix far.
when run script on batch of 360 files (asking load in 360 .max files, perform operations on them, calculate number of values each file , write these values number of text files) ram usage rises 100% , after amount of files have been processed windows gives me message saying 'close down programs prevent data loss'. @ same time maxscript crashes , throws error 'unknown system exception memory error'
when load less files, example 100 memory error not occur, process finishes , files produced. extremely high memory usage still occurs though (12-13gb 3ds max whilst running script), after script has finished memory usage remains same. i've noticed harddrive being filled data whilst script running (13gb added appdata folder every file opened/processed, once scene reset these 13gb removed appdata , after loading next file process repeats)(i have no clue how data added since .max file 2 mb (i load same .max file each iteration) , text files producing script 1.53mb of them).
my script following:
1) rotates object initial rotation (rotation of obj around world z axis)
2) rotate object local y axis in steps of 1 degree
3) calculate variable called rot_ratio (stands rotation ratio) *the variable rot_ratio helps me determine how object 'fits' viewport (when viewed 'front view' camera)
4) format calculated rotation ratio value external file (local rotation angle corresponding rot_ratio added external file)
heapsize = 7.5*10^6 -- set heapsize 7.5 mb obj_world_rotation ; thedummy ; theobj ; rot_ratio_abs resetmaxfile undo off( redraw off( fn fn_calc_rot_ratio x =( obj in geometry ( if (matchpattern obj.name pattern:"_copy") ( resetxform obj ; maxops.collapsenodeto obj 1 true --reset xform + collapse stack rot_ratio = ( ((-1 * obj.min.x) + obj.max.x) / ((-1 * obj.min.z) + obj.max.z) ) / ( renderwidth / renderheight float) - 1 --calculate rotate ratio, lower value (ignore + or -) = closer render aspect ratio rot_ratio_abs = abs rot_ratio ) ) ) fn calc_data b =( in_file = "c:\\users\\god\\desktop\\p90 (single obj).max" out_dir = "c:\\users\\god\\desktop\\359 2\\" steps = (b-a) ; print(steps) steps = steps-1 in 0 steps do( resetmaxfile #noprompt loadmaxfile in_file quiet:true #noprompt obj in geometry ( if (matchpattern obj.name pattern:"_copy") do( theobj = obj select obj ) -- end if obj.name matchpattern pattern:"_copy" do( ) -- end obj in geometry theobj.rotation = eulertoquat (eulerangles 0 0 i) -- set initial rotation obj (world coordinates) obj_world_rotation = $.rotation clearselection() thedummy = dummy isselected:on selectmore theobj thedummy.rotation = obj_world_rotation dummy_and_obj = selection array out_name = out_dir + string + ".txt" out_file = createfile out_name -- create external file close out_file -- close external file j in 0 steps do( theobj.parent = thedummy -- link dummy/obj thedummy.transform = (rotateymatrix 1 ) * thedummy.transform -- rotate dummy/obj local y-axis theobj.parent = undefined -- unlink dummy/obj --calc rot ratio fn_calc_rot_ratio 1 --open ext. file fs = openfile out_name mode:"a" --format [angle rot_ratio_abs \n] external file format "% % \n" j rot_ratio_abs to:fs --format precalculated value of rotation ratio exteral file (without newline) close fs -- close external file ) -- end j in 0 (steps-1) do( delete thedummy -- delete dummy obj ) -- end in 0 (steps-1) do( ) -- end fn calc_data b =( -- call main function (structure: calc_data --> fn_calc_rot_ratio) calc_data 0 110 ) --end redraw off ) --end undo off
i've tried increasing heapsize, clearing max's memory in first few lines of script, adding garbage collection commands throughout script (i know little garbage collection placement of these commands better). i've freed 50 gigs on ssd prevent issues drive filling (need disk space 13gb being written appdata). i've tried increasing virtual memory 10 , 20gb (as suggested on forum).
info testing other .max files: input/output directory defined in lines 17,18, please change username own testing. current script simplified as possible readability , result works scenes containing single object editable mesh. i've attached scene used testing in .max format (for 2014, 2015, 2016, 2017 versions of max) , in .obj format. .max files can downloaded here: http://www.scriptspot.com/forums/3ds-max/general-scripting/memory-error-system-exception-crazy-ram-usage
any appreciated, thank you! -maarten
Comments
Post a Comment