[Editor modules] Garbage Collector debugging

Hello everyone.

TLDR. Teach me how to debug GC actions or get more info about GC activity.

I’m writing a module with a custom editor and with bunches of customizations, etc.
So I’m inheriting from FGCObject to notify GC about some of the assets.

Problem is, I have a few crashes that happen during garbage collection. And it’s very hard to identify the cause sometimes
I have no idea why because crashes are caused by broken/halfdeleted/nullptr(no idea what)

I’m using Visual Studio debugger, yet all I can see is a broken object and have no idea how to identify at least what object it was.

example: crash in function InternalHandleObjectReferencewith error “*Invalid object in GC: 0x%016llx… *”
this was caused by calling DetailBuilder.ForceRefreshDetails();
and the crash was fixed by removing unnecessary reference to Material used in the ViewportClient class that has no relation to details customization.

Another example is referencing the asset that being edited in asset editor class(AssetToolkit). This common action done in many engine plugins will also cause a crash during GC, but now when closing editor.
Looking at the source code, adding asset references to garbage collector when Inheriting from AssetToolkit is unnecessary because AssetToolkit already does it.

In my case, almost all crashes were because assets were added to GC twice, yet plugins like Paper2D can do it too but without crashes.

Are you maybe overcomplicating things?
I just use TWeakObjPtr<>, I won’t have hard pointers to the object I edit in the Toolkit so GC won’t crash when Editor shutdown.

Of course, I’m overcomplicating things, but I’ve been copying things from Plugins and never thought about this before things started falling apart

I can use TWeakObjPtr, and currently, the only thing that uses FGCObject is Viewport class(this one is unnecessary too)
But now I’m unsure why such overcomplication was used in plugins when FPreviewScene will send objects to GC, Toolkit will do it too, yet assets are referenced second time in custom editors and viewports.

PS. Main reason for FGCObject was to load some additional assets by the editor, but by now I’ve given up on this and decided to make transient properties in the asset, which is waaay safer.