SketchUp experiences a period of significant lag after running complex calculations on macos

I have a MacBook Pro with an M1 Pro chip and 16GB of memory. After performing complex calculations, the CPU usage immediately reaches 100% and stays there for a while. The more complex the calculation, the longer the lag persists. During this time, SketchUp becomes very laggy, although other programs continue to run smoothly. When running the same program on Windows, the execution time is slightly longer, but there is no lag afterward. Below are the test files and code for macOS users to test.
test-for-macos-2.skp (2.3 MB)
test_code.rb (345 Bytes)

I ran the script on my Intel Mac, in 2024 and 2023. The memory usage went up to 3.2 GB in 2024 and 3.7 GB for 2023. In both cases the memory didn’t free up when the script ended.

I will check with developers if that is expected behavior when running your script.

I also ran the script on my Intel MBP. I added a calculation of elapsed time, both to get the actual calculation time and to provide a visual of when the operation completed vs other things happened. The operation itself took about 81-82 seconds. SketchUp’s memory usage grew to 2.75GB during that time. There was a pause of about 3-4 seconds afterward before SketchUp became responsive again. Without proof, I speculate that may have been Ruby garbage collection. It’s hard to know what is going on while SketchUp is unresponsive.

I think that is normal. I have often seen SketchUp “high water mark”, i.e. it does not release memory after the need for it passes.

Edit: I added a couple more times and found that there is about an even split between the processing time and the operation commit time. That doesn’t really tell me anything about the lag afterward, but it seemed interesting…

Some more unproven theories:

  • It could be that the laggy period is while SketchUp redraws the model view, which no longer has shared components to draw on.
  • If you have the components window open, it could be while SketchUp generates the thumbnail images for all the newly unique components. That doesn’t take long on my MBP, but it definitely continues after the operation is completed. Many of them don’t fill in until the components window scrolls to see them, as if there is a separate thread working on them in the background. Try putting the components window in list view and see if that improves things.