So I made a simple Web crawler which works very well until at some point after fetching a few hundred pages causes an OutOfMemoryError. More specifically, the next() method of a scanner object does so. I've tried everything from forcing garbage collection to shaking my laptop pretty hard to make it work, but I just couldn't figure it out, but I'm sure it's something pretty stupid.
I would be immensely thankful if someone could help me with this and pay this person a virtual beer.
Here's the piece of code that doesn't work: