Memory check should come first to avoid spurious warning on windows