Memory not freed for retained message topic tree

While using mosquitto(v2.0.10) in our application, I found that if we keep posting retained topics memory increases but it doesn’t go back to normal even if we remove those retained messages.

After examination I found, it allocated memory for retained message payload and topic tree nodes. But when we remove retained message it deallocates memory only for payload but not topic tree nodes. These topic trees are getting cleaned only at mosquitto exit.

I am quite surprised why we are not cleaning the unused nodes when we clean the payload. Is it the intended behavior or this was a bug which fixed in some later versions.