I heard that heavy menstrual periods can cause anemia. Is there anything I can do to prevent the anemia?

Yes. Anemia can be treated with iron supplementation. The key though is to fix the underlying cause. Discuss treatment options for heavy periods with your obgyn. If you still want children then birth control pills can lighten the cycle.. If you are done with pregnancies you may be a candidate for an in office endometrial ablation to lighten or stop your cycles.
Take iron. You can take an over the counter iron supplement. Check with your doctor first to make sure there aren't other reasons why you are having anemia, and to suggest the proper dose for you. Too much iron in certain people can cause chronic liver damage.