Magnesium is a mineral that plays important roles in the structure and the function of your body. In particular it helps with heart rhythm, muscle and nerve function and teeth and bone strength. Magnesium will not be created nor destroyed by cooking or freezing. Only small amounts will be lost from vegetables during cooking by leaching into the cooking water (5% loss).
Try to cook with a just single layer of vegetables in your pan at a time. Overcrowding prevents even cooking and you run the risk of ending up with mushy veg on the bottom.