Memory allocation cuda c++

Hi, I wondering about sample calculation on gpu. Let say I have got X MB Memory and two matrix I want to multiplicity them. What it is the biggest matrix size that gpu can handle ?

Just to get an idea,

matrix mul requires 3 matrices:
A * B = C

Each matrix is n x n so you have that:
3n^2 <= X

therefore you need to satisfy
n <= sqrt(X/3)

In theory the largest size would be n = sqrt(X/3), but I would always leave some small amount of MBs of free memory.