STLPORT vector Resize失败具体是执行到:
template <class _Tp, class _Alloc>
void vector<_Tp, _Alloc>::_M_insert_overflow(pointer __pos, const _Tp& __x, const __true_type& /*_TrivialCopy*/,
                                             size_type __fill_len, bool __atend ) {
  const size_type __old_size = size();
  size_type __len = __old_size + (max)(__old_size, __fill_len);  pointer __new_start = this->_M_end_of_storage.allocate(__len, __len);
  pointer __new_finish = __STATIC_CAST(pointer, _STLP_PRIV __copy_trivial(this->_M_start, __pos, __new_start));
  // handle insertion
  __new_finish = _STLP_PRIV __fill_n(__new_finish, __fill_len, __x);
  if (!__atend)
    __new_finish = __STATIC_CAST(pointer, _STLP_PRIV __copy_trivial(__pos, this->_M_finish, __new_finish)); // copy remainder
  _M_clear();
  _M_set(__new_start, __new_finish, __new_start + __len);
}中坚的pointer __new_start = this->_M_end_of_storage.allocate(__len, __len); 得到的__new_start为空,但是我的内存还够用

解决方案 »

  1.   

    仔细看一下(__len, __len)的值是多少。有时候如果栈被搞乱了,len的值会受到影响。
      

  2.   

    这个值是正常的,我看了的,大概100M数组确实需要有那么大查出来,确实是内存不够了,但是实际物理内存还有200M,虚拟更多,但是分配一个100M的数据已经获取不到了;STLPORT4.5.3中new失败会返回一个NULL, 在最新的STLPORT 5.1.5中,会跳出一个异常只是觉得奇怪,为撒会分配不到内存