Please also check your blood sugar when you feel like this.
Up to 50% with migranes have low magnesium. There are many causes of low magnesium from diabetes to stress to sugar. There are a lot of reasons for memory loss but that includes stress, not enough sleep, too low or high blood glucose levels and to a lesser extent low magnesium. Also the diabetes drug metformin is known to cause low vitamin B12 levels. Low levels of B12 also cause memory loss, fatigue and many other health problems.