Memory Check for Cholesky Decomposition in CDJK.cc

Dear Psi4 Experts,

When a CD calculation is requested by user, a memory check is performed by libfock/CDJK.cc, and when this check thinks that there is not enough memory, a calculation is aborted early.

///Kinda silly to check for memory after you perform CD.
///Most likely redundant as cholesky also checks for memory.
if ( memory_  < ((ULI)sizeof(double) * three_memory + (ULI)sizeof(double)* ncholesky_ * nbf * nbf))
   throw PsiException("Not enough memory for CD.",__FILE__,__LINE__); 

This prevents running some larger CD-OCC calculations that complete happily with DF-OCC. Without quite knowing the actual algorithm requirements, it seems to me that this check is too stringent, at least for some CD calculations. For example, I am able to run a CD-MP3 calculation through the OCC module:

set globals {
   basis aug-cc-pVTZ
   freeze_core true
   scf_type cd
   mp_type cd
   qc_module occ
}

set dfocc {
   wfn_type DF-MP3
   orb_opt false
}

on a larger system (644 basis functions) just fine after I edited CDJK.cc to bypass this memory check. Looks like about half of my available memory is actually used.

Available memory                      :  45776.37 MB
Memory requirement for 3-index ints   :   6427.82 MB
Memory requirement for DF-CC int trans:  19547.11 MB
Memory requirement for CC contractions:  11704.50 MB
Total memory requirement for DF+CC int:  18132.32 MB
Memory requirement for Wabef term     :  15633.62 MB 

Could it be that the memory check in CDJK does not anticipate correctly the efficiencies of the new MP and CC algorithms provided via the OCC module?

P.S. Congratulation to developers on getting the Psi4 1.1 paper accepted!

I encounter the same problem.
Maybe I am wrong, but I think the if statement is incorrect.
In HF::integrals() in hf.cc, the memory is set to Process::environment.get_memory() / 8L.
Thus there is no need to time sizeof(double) of three_meemory and so on.