Currently, the form of ::operator new() is used, which throws std::bad_alloc upon failure. Since we don't have handling of c++ exceptions in the code, such failures wouldn't be handled. Instead, ::operator new(std::nothrow) can be used, which would return 0 in a case of a failure. Then we can (try to) throw Java exception of type OutOfMemoryError.