quering remaining available global memory

I get unknown error after several memory allocations and in the emulation mode i get access violation in another memory allocation that’s in the code sequence after the one that cause the unknown error.
Is there a way to query the remaining available global memory, as i doubt i allocate too much memory and it’s the reason of the errors.