Script Debugger hangs

Recently, SD has been occasionally hanging when I try to save and less often when trying to compile the main script in my applet. Sometimes, it hangs when it indicates it’s trying to save a binary executable unrelated to AppleScript (I don’t understand why). I’ve attached a capture of a dialog SD showed just before one of the hangs:
SD crashes

I have to use command-alt-esc to force quit SD before I can do anything else with it.

The hangs don’t happen every time I save/compile (maybe 1 hang in 10 saves). I haven’t found a pattern as yet. When I reopen SD, it pulls up the autosaved copy of my script and continues on happily.

I have attached a copy of the most recent diagnostic report.
Script Debugger_2021-01-04-165136_iMac.hang.zip (112.1 KB)

I’m worried that the problem is my applet. The main.scpt file is over 3,500 lines including comments and blank lines (I use spacing to make scripts more readable). It has 42 handlers. There are also a lot of global variables some of which are used in almost all the handlers. The applet also has 2 more small scripts (which when called run in background), 4 lproj folders, a script library, the executable mentioned above, an automator service and a PDF help file.

I’ve also noticed that SD can be very slow to respond to typing – I can type some code and watch it appear in the SD editor window character by character, perhaps 2/second and slower.

I could move some of the handlers out to separate scripts which are called when needed but, would that help ? Could there be something I’ve done causing the hangs ?

Thanks.

Garry
[SD v7.0.2, iMac late 2009, i5, 12GB, 1TB SSD, macOS 10.15.7 (patched)]

I suspect your concern is fully justified — it sounds like you’re crashing AppleScript because the script is too big.

Definitely.