I have C implementation of an algorithm that includes shared library. The performance of the shared library is considerably different in C and C++ (performing much better in C++). Therefore, I have changed the shared library parts of the C implementation (Imp-1) into C++ (Imp-2) while keeping the rest of it same. I have compiled Imp-1 and Imp-2 by using gcc and g++ in Linux, respectively. In small sized problems both Imp-1 and Imp-2 perform exactly same. However, in a same large sized problem while Imp-1 solves it without any problem, Imp-2 returns std::bad_alloc error. Interestingly, this error occurs when the memory usage increases to 4GB where the available memory is 35GB.
为什么出现这一错误? (研究员、操作系统、汇编办法等)
最佳方面。