Joplin should delete unused resources after a set time. I cannot recall what that time period is, however I am sure @laurent mentioned it recently when replying to a post on this very topic.
I am not sure that it is working as efficiently as it could and if you actually search this forum for postings on orphaned or unattached resources you will get quite a few hits.
One such post from a few days ago that summarises the situation is: