You’re running in a while(true), which means RuuviTag cannot sleep and power consumption is large.
You’re setting the setInterval() in a for-loop 500 times which gives you 500 instances of function running at interval
The for-loop is within while(true), so you’re adding the setInterval() instances until you run out of memory. Using flash would not help here, you’d fill the flash almost instantly.
Try implementing the FIFO push and pop -functions, and calling those from one setInterval-function.