Memory management of data on the beam is a black box to users of beam languages. It’s handled completely by the vm. Detecting problems with it is somethings you’d do it like for any other problem, which is caused in a black box. Form a hypothesis, change the code in a way aligned with said hypothesis and by observing the results see it supported or not. If you want a more straight forward way you need to open the black box and look into it.
Take for example the optimisation that small maps are stored as tuples by the vm. The only way to observe that from elixir is that keys keep their order in certain scenarios. Those can be found if you look hard for them. You might be able to infer the connection to tuples based on keys keeping the order, which is not how maps usually work. But there’s no way in elixir to access the “tuple” form of the map or test for it being a tuple specifically. If you want to ensure the optimisation is using a tuple you’ll need to drop to lower levels.