Unstability of Codea when reading a Multi-page pdf file.

I have ben using some 50 image files (png) as sprites. I want to put those images together into one pdf file and get them with “readImage()” command by specifying corresponding page. Since the size of individual files are slightly different, I wrte "myImage = readImage( Dropbox:fileName, _ , _ , pageNumber), and sprite(myImage, x, y, width) "
It worked and I could see the image, however, Codea crashed right after the action.
I get the same results when I specify width and height in readImage() command.

Is there any tips to stabilize for multi page pdf reading? Should the size of each page the same?

Try adding collectgarbage() in the routine. It recovers unused memory each time it’s called. Running out of memory might be the cause of the crash.

Thank you for your prompt suggestion.
Actually, I placed the readImage() command in the draw routine, so that it makes too many access to the memory.
By putting a flag to limit access to memory, it become stable. I learned I must be careful about handring the draw routine archtecture of Codea.
But I also learned that collectgarbage() might be a nice tip to overcome future crash problem.