It's to do with the "keypool"... the system used to maintain 100 keys in a "pool", modern versions of Bitcoin Core have a pool of 1000... so it does the generation all at once and fills the pool up. Once it runs out of available keys in the pool, it then regenerates another 1000 (or 100 for the older versions etc).
For older (non-hd) wallets... it's important to make regular backups, otherwise, you might be using addresses/keys that aren't actually backed up!
(This is a non-issue for HD wallets).
Clear. Thanks.
I noticed another interesting thing. It looks like addresses from the pool are being used for change. I'm not sure about this. But it seems to me that sometimes
getnewaddress does output with address that already have balance (comes from change)
Like this:
the first call
getnewaddress generates an array [addr1, addr2, ... addrN] and outputs "addr1"
If I call
sendmany then one of [addr2, ... addrN] is used for change ("addrK" then got a balance)!
One of the subsequent calls
getnewaddress does output "addrK".
I'm pretty sure this is exactly how it works in Dogecoin. Does newest Bitcoin RPC work the same way?