How to remove object from asset file

I wonder if it is possible to delete objects that has been added to a .asset file ? The asset file are used as storage for an Editor window, and objects are added to it continuously which creates a bit of storage problem ( in the very long run ) if it is possible to clean it up ones in a while.

As far as I know deleting .asset files is no good. As that will either make the scene not load up or Unity might just recreate the .asset files again after deletion.

I haven't tried this myself, but I think what you can do is recreate the asset once in a while using AssetDatabase.CreateAsset(). If you overwrite the same file, it should maintain it's GUID, so references references wouldn't have to break.

It might still break, because we store references to objects like this; (AssetFileGUID, IndexOfObjectInFile). so you if you want to remove objects from that, that actually gets quite tricky. It depends on how you reference these objects though. If instead of storing direct references to them, you use LoadAssetFromPath() or similar function, and i.e. look up the object by name or type like that, you could be just fine.