Ruby slowdown
-
I've noticed that the performance of my plugin degrades the longer I keep Sketchup open. All I'm doing in my plugin is modifying attribute dictionaries on various entities and coloring and/or showing/hiding based on their attributes. I can close/reopen Sketchup and run the exact same test case and see things perform noticeably faster.
I realize that my question here is sufficiently vague, but was wondering if anyone had encountered anything like this and/or had any pointers on how to proceed in debugging.
Some things that I've considered could be going wrong are
- garbage collection - not quite sure how to debug this
- undo/redo stack memory consumption - memory seems to be staying constant, and I'm using the start/commit operations on the model to limit undo/redo activity
Any pointers here would be greatly appreciated.
Thanks again,
Josh -
Force Garbage Collection via:
GC.start()
And saving the model will clear the undo stack.
-
If you're using the Ruby Console for debugging output, SketchUp gets progressively slower the more lines that are added.
I use either the Ruby Toolbar plugin or an AHK short-cut to clear the Ruby Console.
-
I am using the ruby console, maybe thats it.
Regarding undo/redo, is there any way to disable that using the API? I'm using the start/commit methods to store a single entry on the stack but that single entry still seems to consume as much memory as all of the individual actions would. It would be really nice to either be able to turn that off or to clear the stack manually without forcing a save.
thanks,
josh -
Printing to the console will slow things greatly...
-
We don't have direct control over the undo stack via a Ruby class.
There is a Registry key that sets max number of undo ops... but I do not think it is exposed to the user via the app's UI. (The default is 100 I think.)
-
@tig said:
Printing to the console will slow things greatly...
That's a good pointer - if you use the Ruby Console to debug then the more you output the more it slows down.
I use a small snippet that uses the Win32 API to clear the content of the console in order to keep it responsive. I also use Win32 to output data to DebugView.
Advertisement