Rik,
As others above have already pointed out, there is a limit (which can be increased) of 10,000 GDI handles and you've hit it. (btw, increasing the limit is _not_ a good idea.)
In addition to that, as you have already noticed, your program is a memory hog. I attached a small screenshot showing that your program did hit the limit and that it was using 2.5GB of memory when it did.
You mentioned that the reason you were doing this is because your computer was too slow to render the images in real time. Using 10,000 handles and several gigabytes of memory is not going to make any computer faster, on the contrary, that guarantees that most machines would be overwhelmed if it worked.
One possibility you may want to look into is creating a Windows Metafile which your program can play. For the record, I have no idea if there is a component in Lazarus to play a WMF but, if there is, that might provide a reasonable, as well as, reasonably fast and simple solution.
In other words, your program needs to manage resources a little more efficiently.
Hopefully, someone who knows what Lazarus can do, can give you an example on how to play a Windows metafile which you could use for what you need to do.
HTH.