Batch Delete SME error

Batch Delete SME error

victorEFVH7
Enthusiast Enthusiast
1,101 Views
8 Replies
Message 1 of 9

Batch Delete SME error

victorEFVH7
Enthusiast
Enthusiast

Im trying to batch delete the SME in multiple maxfiles with Pen Tools - Batch it all. Im truggling with some crashes after everything from 5-100 maxfiles or so, sometimes more sometimes less.

When I start over at the same file that caused the crash then its working so its hard to figure out what it is.

 

Most of the crash occur without even a CER or not possible to access the listener.

Im used to crashes in batches after a couple of 100 maxfiles but not after 5 or so, its getting a bit annoying.

 

Could it have to do if there are 0 views or 0 materials in the slate?

 

This is the batch code that im running together with sme global rendering off

 

 

fn sme_deleteAllViews open:off delNodes:on delRef:on delView:on = undo off
(
	if open then sme.open() else sme.close()
	
	k0 = sme.getnumviews()
	
	for k = sme.getnumviews() to 1 by -1 do
	(
		v = sme.getview k
		format "%:\n" v.name
		if delNodes do
		(
			n0 = v.getnumnodes()
			v.selectall()
			v.deleteselection()
			n1 = v.getnumnodes()
			format "\t% > nodes: %(%)\n" k n1 n0
		)
		if delRef do
		(
			r0 = refs.getreference trackViewNodes[#sme] k
			refs.replacereference trackViewNodes[#sme] k undefined
			r1 = refs.getreference trackViewNodes[#sme] k
			format "\t% > reference: %(%)\n" k r1 r0
		)
		if delView do
		(
			sme.deleteview k off
			k1 = sme.getnumviews()
			format "\t% > views: %(%)\n" k k1 k0
		)
	)
	(k0 - sme.getnumviews())
)

sme_deleteAllViews open:on delNodes:on delRef:on delView:on
for i = 1 to 24 do meditmaterials[i] = vraymtl()
clearListener()
gc()

 

 

This is the latest error Im getting, not always able to catch a CER for some reason.

 

 

View5:
	5 > nodes: 0(10)
	5 > reference: undefined(<Deleted trackview node>)
	5 > views: 4(5)
View4:

-- Error occurred in anonymous codeblock; filename: D:\Scripts\DeleteSME_Fn.ms; position: 758; line: 32
-- MAXScript Rollout Handler Exception:
-- Known system exception
-- ########################################################################
-- Address: 0x395d4783; nCode: 0x00000000C0000005
-- Desc: EXCEPTION_ACCESS_VIOLATION The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
--       Read of Address: 0x000006D100000687
-- ########################################################################
-- MAXScript callstack:
--	thread data: threadID:21968
--	------------------------------------------------------
--	[stack level: 0]
--	In k loop; filename: D:\Scripts\DeleteSME_Fn.ms; position: 334; line: 15
--		Parameters:
--			k: 4
--		Locals:
--			r0: undefined
--			n0: 407
--			V: <IObject:IFP_NodeViewImp>
--			n1: undefined
--			k1: undefined
--			k: 4
--			r1: undefined
--		Externals:
--			trackViewNodes: SystemGlobal:trackViewNodes : TrackviewNode:root
--			k0: Free:k0 : 5
--			delRef: Free:delRef : true
--			owner: undefined
--			delView: Free:delView : true
--			delNodes: Free:delNodes : true
--	------------------------------------------------------
--	[stack level: 1]
--	called from sme_deleteAllViews(); filename: D:\Scripts\DeleteSME_Fn.ms; position: 759; line: 32
--		Parameters:
--			open: true
--			delNodes: true
--			delRef: true
--			delView: true
--		Locals:
--			k0: 5
--			delRef: true
--			delView: true
--			open: true
--			delNodes: true
--		Externals:
--			owner: undefined
--	------------------------------------------------------
--	[stack level: 2]
--	called from s loop; filename: D:\Scripts\DeleteSME_Fn.ms; position: 827; line: 35
--		Parameters:
--			s: 2
--		Locals:
--			s: 2
--		Externals:
--			batchList_mlb: RolloutControl:batchList_mlb in rollout:batchUtil_R : MultiListBoxControl:batchList_mlb
--			scriptsIn: Free:scriptsIn : #()
--			batchDir_et: RolloutControl:batchDir_et in rollout:batchUtil_R : EditTextControl:batchDir_et
--			owner: undefined
--	------------------------------------------------------
--	[stack level: 3]
--	called from x loop; filename: C:\Program Files\Autodesk\3ds Max 2021\stdplugs\stdscripts\PEN_batchItMax.ms; position: 11546; line: 376
--		Parameters:
--			x: 52
--		Locals:
--			file: undefined
--			scriptsIn: #()
--			x: 52
--			path: undefined
--		Externals:
--			batchList_mlb: RolloutControl:batchList_mlb in rollout:batchUtil_R : MultiListBoxControl:batchList_mlb
--			dontSaveFilesCb: RolloutControl:dontSaveFilesCb in rollout:batchUtil_R : CheckBoxControl:dontSaveFilesCb
--			owner: undefined
--			getBatchIni_fn: getBatchIni_fn()
--			logFile_fn: logFile_fn()
--			progBar_pb: RolloutControl:progBar_pb in rollout:batchUtil_R : ProgressBar:progBar_pb
--			fileSel: Free:fileSel : 899
--			setLogPath_fn: setLogPath_fn()
--			saveFolder_et: RolloutControl:saveFolder_et in rollout:batchUtil_R : EditTextControl:saveFolder_et
--			maxFiles_mlb: RolloutControl:maxFiles_mlb in rollout:batchUtil_R : MultiListBoxControl:maxFiles_mlb
--			num: Free:num : 51
--			overWrite_cb: RolloutControl:overWrite_cb in rollout:batchUtil_R : CheckBoxControl:overWrite_cb
--	------------------------------------------------------
--	[stack level: 4]
--	called from process_bt.pressed(); filename: C:\Program Files\Autodesk\3ds Max 2021\stdplugs\stdscripts\PEN_batchItMax.ms; position: 12502; line: 411
--	member of: Rollout:batchUtil_R
--		Locals:
--			fileSel: 899
--			num: 51
--			scriptSel: 1
--		Externals:
--			batchList_mlb: RolloutControl:batchList_mlb in rollout:batchUtil_R : MultiListBoxControl:batchList_mlb
--			batchUtil_R: Rollout:batchUtil_R
--			owner: Rollout:batchUtil_R
--			progBar_pb: RolloutControl:progBar_pb in rollout:batchUtil_R : ProgressBar:progBar_pb
--			maxFiles_mlb: RolloutControl:maxFiles_mlb in rollout:batchUtil_R : MultiListBoxControl:maxFiles_mlb
--			escapeEnable: SystemGlobal:escapeEnable : true
--	------------------------------------------------------
--	[stack level: 5]
--	called from top-level
-- ########################################################################
-- C++ callstack:
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (core): (filename not available): ReferenceMaker::DeleteReference
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (SME): (filename not available): ConfigManager::operator=
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (MAXScrpt): (filename not available): Generic::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): save_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): SourceFileWrapper::eval
-- (MAXScrpt): (filename not available): Generic::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): SourceFileWrapper::eval
-- (MAXScrpt): (filename not available): MAXScript::SetMAXScriptListenerLogFile
-- (MAXScrpt): (filename not available): MAXScript::SetMAXScriptListenerLogFile
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): BitArrayValue::map
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): BitArrayValue::map
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Generic::apply
-- (MAXScrpt): (filename not available): SourceFileWrapper::apply
-- (MAXScrpt): (filename not available): RolloutControl::call_event_handler
-- (MAXScrpt): (filename not available): RolloutControl::get_wrapped_event_handler
-- (MAXScrpt): (filename not available): InitMacroScriptDir
-- (MAXScrpt): (filename not available): InitMacroScriptDir
-- (USER32): (filename not available): CallWindowProcW
-- (USER32): (filename not available): DispatchMessageW
-- (USER32): (filename not available): SendMessageTimeoutW
-- (ntdll): (filename not available): KiUserCallbackDispatcher
-- (win32u): (filename not available): NtUserMessageCall
-- (USER32): (filename not available): SendMessageW
-- (USER32): (filename not available): SendMessageW
-- (core): (filename not available): GetICustButton
-- (core): (filename not available): CustomControl::WindowProc
-- (core): (filename not available): AncestorIsCUIToolbarWindow
-- (USER32): (filename not available): CallWindowProcW
-- (USER32): (filename not available): DispatchMessageW
-- (USER32): (filename not available): IsDialogMessageW
-- (3dsmax): (filename not available): NodeAndAnims::SetNode
-- ########################################################################

 

 

 

0 Likes
Accepted solutions (1)
1,102 Views
8 Replies
Replies (8)
Message 2 of 9

denisT.MaxDoctor
Advisor
Advisor

can you delete sme views for the file that is causing the crash not in batch mode? 

try... use the same function but in preloaded scene 

 

does only this particular file cause the crash?

0 Likes
Message 3 of 9

victorEFVH7
Enthusiast
Enthusiast

Yes its not a problem to do it in a single file. If I start the batch from this file then its not a problem either. So its not like its impossible to clean it.

 

No its mulitple files across 30 000 files and its not like its a super complex scene it could just be a super simple model with 2 materials and 10k polys. As i see its quite random. 

0 Likes
Message 4 of 9

denisT.MaxDoctor
Advisor
Advisor

@victorEFVH7 wrote:

 

No its mulitple files across 30 000 files and its not like its a super complex scene it could just be a super simple model with 2 materials and 10k polys. As i see its quite random. 


It can be a memory issue.

It is a well-known practice to do

 

resetMaxFile #noPrompt

 

and 

 

freeSceneBitmaps()

 

every time you upload a new file in batch. It cleans up memory and performs garbage collection ...

do you do it?

0 Likes
Message 5 of 9

victorEFVH7
Enthusiast
Enthusiast

I updated the batch it all script with both of these lines and it worked better, managed to batch 300 before a crash.

Anything else that could prevent eventually memory leaks?

 

COW:
-- Error occurred in anonymous codeblock; filename: D:\Scripts\DeleteSME_Fn.ms; position: 758; line: 32
-- MAXScript Rollout Handler Exception:
-- Known system exception
-- ########################################################################
-- Address: 0x3a0d4771; nCode: 0x00000000C0000005
-- Desc: EXCEPTION_ACCESS_VIOLATION The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
--       Read of Address: 0x000000000000000A
-- ########################################################################
-- MAXScript callstack:
--	thread data: threadID:22928
--	------------------------------------------------------
--	[stack level: 0]
--	In k loop; filename: D:\Scripts\DeleteSME_Fn.ms; position: 334; line: 15
--		Parameters:
--			k: 2
--		Locals:
--			V: <IObject:IFP_NodeViewImp>
--			r0: undefined
--			r1: undefined
--			n0: 637
--			k: 2
--			k1: undefined
--			n1: undefined
--		Externals:
--			owner: undefined
--			delNodes: Free:delNodes : true
--			delView: Free:delView : true
--			k0: Free:k0 : 2
--			delRef: Free:delRef : true
--			trackViewNodes: SystemGlobal:trackViewNodes : TrackviewNode:root
--	------------------------------------------------------
--	[stack level: 1]
--	called from sme_deleteAllViews(); filename: D:\Scripts\DeleteSME_Fn.ms; position: 759; line: 32
--		Parameters:
--			open: true
--			delNodes: true
--			delRef: true
--			delView: true
--		Locals:
--			open: true
--			delNodes: true
--			delView: true
--			k0: 2
--			delRef: true
--		Externals:
--			owner: undefined
--	------------------------------------------------------
--	[stack level: 2]
--	called from s loop; filename: D:\Scripts\DeleteSME_Fn.ms; position: 827; line: 35
--		Parameters:
--			s: 2
--		Locals:
--			s: 2
--		Externals:
--			batchDir_et: RolloutControl:batchDir_et in rollout:batchUtil_R : EditTextControl:batchDir_et
--			owner: undefined
--			scriptsIn: Free:scriptsIn : #()
--			batchList_mlb: RolloutControl:batchList_mlb in rollout:batchUtil_R : MultiListBoxControl:batchList_mlb
--	------------------------------------------------------
--	[stack level: 3]
--	called from x loop; filename: C:\Program Files\Autodesk\3ds Max 2021\stdplugs\stdscripts\PEN_batchItMax.ms; position: 11614; line: 379
--		Parameters:
--			x: 334
--		Locals:
--			x: 334
--			path: undefined
--			scriptsIn: #()
--			file: undefined
--		Externals:
--			owner: undefined
--			getBatchIni_fn: getBatchIni_fn()
--			logFile_fn: logFile_fn()
--			progBar_pb: RolloutControl:progBar_pb in rollout:batchUtil_R : ProgressBar:progBar_pb
--			fileSel: Free:fileSel : 5862
--			setLogPath_fn: setLogPath_fn()
--			saveFolder_et: RolloutControl:saveFolder_et in rollout:batchUtil_R : EditTextControl:saveFolder_et
--			maxFiles_mlb: RolloutControl:maxFiles_mlb in rollout:batchUtil_R : MultiListBoxControl:maxFiles_mlb
--			num: Free:num : 333
--			overWrite_cb: RolloutControl:overWrite_cb in rollout:batchUtil_R : CheckBoxControl:overWrite_cb
--			batchList_mlb: RolloutControl:batchList_mlb in rollout:batchUtil_R : MultiListBoxControl:batchList_mlb
--			dontSaveFilesCb: RolloutControl:dontSaveFilesCb in rollout:batchUtil_R : CheckBoxControl:dontSaveFilesCb
--	------------------------------------------------------
--	[stack level: 4]
--	called from process_bt.pressed(); filename: C:\Program Files\Autodesk\3ds Max 2021\stdplugs\stdscripts\PEN_batchItMax.ms; position: 12570; line: 414
--	member of: Rollout:batchUtil_R
--		Locals:
--			fileSel: 5862
--			num: 333
--			scriptSel: 1
--		Externals:
--			batchUtil_R: Rollout:batchUtil_R
--			owner: Rollout:batchUtil_R
--			progBar_pb: RolloutControl:progBar_pb in rollout:batchUtil_R : ProgressBar:progBar_pb
--			maxFiles_mlb: RolloutControl:maxFiles_mlb in rollout:batchUtil_R : MultiListBoxControl:maxFiles_mlb
--			escapeEnable: SystemGlobal:escapeEnable : true
--			batchList_mlb: RolloutControl:batchList_mlb in rollout:batchUtil_R : MultiListBoxControl:batchList_mlb
--	------------------------------------------------------
--	[stack level: 5]
--	called from top-level
-- ########################################################################
-- C++ callstack:
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (core): (filename not available): ReferenceMaker::DeleteReference
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (SME): (filename not available): ConfigManager::operator=
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (SME): (filename not available): ConfigManager::__autoclassinit2
-- (MAXScrpt): (filename not available): Generic::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): save_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): SourceFileWrapper::eval
-- (MAXScrpt): (filename not available): Generic::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): SourceFileWrapper::eval
-- (MAXScrpt): (filename not available): MAXScript::SetMAXScriptListenerLogFile
-- (MAXScrpt): (filename not available): MAXScript::SetMAXScriptListenerLogFile
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): BitArrayValue::map
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): BitArrayValue::map
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): clear_error_source_data
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Primitive::apply
-- (MAXScrpt): (filename not available): CodeTree::eval
-- (MAXScrpt): (filename not available): Generic::apply
-- (MAXScrpt): (filename not available): SourceFileWrapper::apply
-- (MAXScrpt): (filename not available): RolloutControl::call_event_handler
-- (MAXScrpt): (filename not available): RolloutControl::get_wrapped_event_handler
-- (MAXScrpt): (filename not available): InitMacroScriptDir
-- (MAXScrpt): (filename not available): InitMacroScriptDir
-- (USER32): (filename not available): CallWindowProcW
-- (USER32): (filename not available): DispatchMessageW
-- (USER32): (filename not available): SendMessageTimeoutW
-- (ntdll): (filename not available): KiUserCallbackDispatcher
-- (win32u): (filename not available): NtUserMessageCall
-- (USER32): (filename not available): SendMessageW
-- (USER32): (filename not available): SendMessageW
-- (core): (filename not available): GetICustButton
-- (core): (filename not available): CustomControl::WindowProc
-- (core): (filename not available): AncestorIsCUIToolbarWindow
-- (USER32): (filename not available): CallWindowProcW
-- (USER32): (filename not available): DispatchMessageW
-- (USER32): (filename not available): IsDialogMessageW
-- (3dsmax): (filename not available): NodeAndAnims::SetNode
-- ########################################################################
0 Likes
Message 6 of 9

denisT.MaxDoctor
Advisor
Advisor

try to add maxscript initial heap allocation... make it 200 for example

denisTMaxDoctor_0-1636834365815.png

 

0 Likes
Message 7 of 9

victorEFVH7
Enthusiast
Enthusiast

its already on max with 1024mb unfortunately.

 

0 Likes
Message 8 of 9

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

@victorEFVH7 wrote:

its already on max with 1024mb unfortunately.

 


Well... then you have to come to terms with it. You don't have to do a batch of 30,000 files every day, do you? So do everything in portions of 300 files, and then don't amass 30,000. 😉

 

0 Likes
Message 9 of 9

victorEFVH7
Enthusiast
Enthusiast
Haha, true, its more or less painful to restart the batch every once and then especially because Im batching when I'm away from the office. Max is not known for being the quickest at starting up.

The solution was to create a batch tool that remembers where the array crashed and resumes the batch.