This is not strictly a memory leak rather missing eviction policy on the realmVersions cache. There was also another issue as clearing caches through admin console would not clear the realmVersion cache.
The solution was to remove the realmVersion cache. Instead two separate caches are created internally realmRevisions and userRevisions. The realmRevisions cache has an hard-coded maximum entries set to 10K, while the userRevision cache is set to the max entries of the userCache. If the userCache doesn't have an eviction policy set the userRevision cache is set to maximum 100K entries.