I am having issues with what appears to be a memory leak. When I run my code, the memory usage keeps increasing until the application crashes.
I have been using the GC.start to be sure that all the unused objects are removed. I am also using the ObjectSpace module to track down the culprit, but I have not been able to understand what's happening.
In this file https://www.dropbox.com/s/0j75ylcsj3rs0ro/Log_1.txt I have logged the output of ObjectSpace count_objects. The first output from the command is before one big for-loop. At the end of each loop I use GC.start. From what I see, the total number of object stays constant during the for-loop, however the memory used by the application keeps increasing.
A stripped down version of the code is at this link https://www.dropbox.com/s/5fnludxurs1ljy8/Shading.rb
Problem solved! I have learned that if you use variables with capital letters they are considered constants and, apparently, even if you reassign them, memory is never freed. I had 5 variables beginning with capital letters and I was re-assigning them a few million times in the loops. Changing to lower case has solved the problem. No more memory issues.