Inverting a Large Matrix

I need to calculate the inverse of a large matrix (40_000 x 40_000) multiple times in a loop. How can I do it efficiently? I've tried multiple different functions, like solve or cholesky decomposition, but everytime I get an error regarding memory.

Do you have 64 bit R installed? That makes a big difference in memory available.

Does this matrix have a certain pattern of sparsity? These are exploitable.

If your memory can do 1 at a time then you could make a process to write out the result and reuse the memory when processing the next, instead of maintaining all the calculated results in memory throughout your session.