Attaching lots of objects shouldn’t bloat the file. It does seem to increase memory usage while the file is open and not free it correctly. Might be the undo buffers that do that. Saving and reloading should clear that though and it shouldn’t affect file size.
30-40 materials isn’t a lot, but are they all massive multi-sub mats? I was talking about something like 250 multi-sub materials some of which had 250 subs in them.
Having materials in the material editor does bloat the scene, especially if they aren’t used. That might be why merging helped. I think it keeps all the textures for the sample spheres loaded or something.