Gretzky also did it in a time when the NHL was averaging 2+ more goals per game than they have been during Ovechkin's career. It cuts both ways. If you start to look at era adjusted numbers, Ovechkin's best season in terms of goals beats Gretzyk's best.
But even ignoring era adjustment which definitely has flaws:
Gretzky led the league in goals 5 times and finished in the top 10 in goals 9 times in his career. Never once in the back half of his career
Ovechkin has led the league in goals 9 times and finished in the top 10 in goals 15 times (tracking for a 16th this season).
Ovechkin's longevity is freakish and gives him the edge over Gretzky as greatest goal scorer of all time imo.