public boolean tryReserve ( QueryId queryId , String allocationTag , long bytes ) { checkArgument ( bytes >= 0 , "bytes is negative" ) ; synchronized ( this ) { if ( getFreeBytes ( ) - bytes < 0 ) { return false ; } reservedBytes += bytes ; if ( bytes != 0 ) { queryMemoryReservations . merge ( queryId , bytes , Long :: sum ) ; updateTaggedMemoryAllocations ( queryId , allocationTag , bytes ) ; } } onMemoryReserved ( ) ; return true ; }
Try to reserve the given number of bytes . Return value indicates whether the caller may use the requested memory .