There's a bug in address generation, that causes generation time to be O(N2) of the number of addresses you want to generate only if the wallet is encrypted. Therefore, you should only generate up to 500 addresses at a time ,if it's encrypted. If you make the wallet unencrypted first, you can do any number in O(N). Of course, most people don't want to write an unencrypted copy of their wallet, but it may be the only real way to work around this.
There is a work around if you modify the code directly, and make the walletLockTimeout > 10s. Make it like 10 min. Then unlock your wallet anywhere in the app, and it will remain unlocked for 10m. Then go generate your 1,000,000 addresses. (btw, 237 bytes on disk for every address you calculate)
The new wallet format should resolve this issue. Until then, you'll have to work around this constraint.
Btw, the operation is in the GUI, in Expert usermode, within the wallet properties. Click on "# Addressses used"
Thanks it worked!