**Memory error** System exception (crazy RAM usage)

Hello all,

I am getting a memory error and have been unable to fix it thus far.

When I run my script on a batch of 360 files (asking it to load in 360 .max files, perform some operations on them, calculate a number of values for each file and write these values to a number of text files) the RAM usage quickly rises to 100% and after a certain amount of files have been processed windows gives me a message saying 'close down programs to prevent data loss'. At the same time maxscript crashes and throws the error 'unknown system exception *memory error*'

When I load less files, for example 100 the memory error does not occur, the process finishes and the files are produced. The extremely high memory usage still occurs though (12-13GB for 3ds max whilst running script), after the script has finished the memory usage remains the same. Also I've noticed the harddrive being filled with data whilst the script is running (13GB is added to the appdata folder for every file that is opened/processed, once the scene is reset these 13GB are removed from appdata and after loading the next file the process repeats)(I have no clue how that much data could be added since my .max file is 2 MB (I load the same .max file each iteration) and the text files I am producing with the script are 1.53MB for all of them).

My script does the following:
1) Rotates object to initial rotation (rotation of obj around world Z axis)
2) Rotate object about local Y axis in steps of 1 degree
3) Calculate a variable called rot_ratio (stands for rotation ratio) *The variable rot_ratio helps me determine how well the object 'fits' into the viewport (when viewed from a 'front view' camera)
4) Format calculated rotation ratio value to external file (local rotation angle corresponding to this rot_ratio is also added to external file)

I've tried increasing Heapsize, clearing max's memory in the first few lines of the script, adding garbage collection commands throughout the script (I know very little about garbage collection so the placement of these commands could definitely be better). I've freed up 50 gigs on my SSD to prevent issues with my drive filling up (need disk space for the 13GB being written to appdata). I've also tried increasing my virtual memory to 10 and 20GB (as suggested on another forum).

Info for testing with other .max files: input/output directory are defined in lines 17,18, please change username to your own for testing. Current script is simplified as much as possible for readability and as a result only works with scenes containing a single object which is an editable mesh. I've attached the scene I used for testing in .max format (for 2014, 2015, 2016, 2017 versions of max) and in .obj format.

Any help will be greatly appreciated, thank you! Laughing
-Maarten

AttachmentSize
calc_data_1_3_desktop_edit_4.ms2.35 KB
p90_single_obj2014.max1.51 MB
p90_single_obj2015.max1.51 MB
p90_single_obj2016.max1.51 MB
p90_single_obj.max1.35 MB
p90_single_obj.obj812.33 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
fajar's picture

this is strange script.....

I dont know what your script does for, is it for pulling some data from current operation or else , but I notice your script need a lot improvement tho...I don't know why you link them and unlink them at almost the same time before calculate, so whats the point?, and theres resetmaxfile everywhere which you can simplify by using one reset for current file , in "fn fn_calc_rot_ratio x" , whats even x stand for ? theres no need to selectmore() , or clearselection() needed in your script, you just need collect them, one time only, like (for i in geometry where (matchpattern i.name pattern:"_copy") collect i) .

1. Dummy_and_obj = selection as array --- whats its for ? 
2.out_name = out_dir + i as string + ".txt"
		out_file = createfile out_name -- Create external file
		close out_file -- Close external file
---why not create and write it in and then close it ? 
3. theobj.parent = thedummy -- link dummy/obj
			thedummy.transform = (rotateYmatrix 1 ) * thedummy.transform -- Rotate dummy/obj local Y-axis
			theobj.parent = undefined
--its make no sense in this script tho ? whats for ? should you just , if my feeling is correct , you should link them , rotate them and then pull data from it , write it and then unlink , delete it, later just close the outfile ?

Thanks

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.