See stack trace and code below. I'm working with a pool of threads that simulates bank transactions, and I'm having a strange problem. I'm running out of memory, but am really not instantiating THAT many objects. Maybe I have some kind of memory leak or am doing something silly that I'm overlooking? Could someone point me in the right direction? As usual, thanks in advance!
Hello. My name is Inigo Montoya. You killed my father. Prepare to die.
Actually, you are creating a whole hell of a lot of accounts here:
That "i--" means you subtract 1 from i each time through the loop, and keep going as long as i is less then 1000. Well, i will start at 0, and become -1, then -2, then -3, and so on until you get to the largest possible negative int, which is a little over 2 billion. And that's a lot! At that point, subtracting 1 from the largest negative int will underflow and give you the largest possible int, which is larger than 1000, so the iteration stops.