OutOfMemoryError()_solved by sparse matrix

“I kept adding rows where few of the columns contained data”
Sparse matricies (click for docs) sound appropriate.

Another good practice is to preallocate (and zero) the size needed then put values into it, rather than continually adding onto it.

“what’s recommended in this” (about Garbage collection)
Try running it with smaller data matricies first; when it works run it with the larger data matricies.

I agree about the threads; there is little reason to introduce threading before all the other aspects of the project have been worked out.

happy to be of help