【发布时间】:2021-07-15 23:25:29
【问题描述】:
大家!
我在 SGX 飞地内使用 NTL。当我运行应用程序时,我遇到了关于out of memory 的问题。然后我检查了内存,我猜是由于大量使用了NTL矩阵。
NTL中矩阵的基本使用:
Mat<size_t> mtemp;
mtemp.SetDims(num_row, num_col);
在NTL matrix.cpp,我没有找到任何释放内存的函数。
对于kill(),实现大概是swap():
template<class T>
void Mat<T>::kill()
{
Mat<T> tmp;
this->swap(tmp);
}
void swap(Mat& other)
{
_mat__rep.swap(other._mat__rep);
_ntl_swap(_mat__numcols, other._mat__numcols);
}
template<class T>
void _ntl_swap(T*& a, T*& b)
{
T* t = a; a = b; b = t;
}
这无助于释放矩阵的内存。使用后如何释放内存?
【问题讨论】:
标签: c++ memory-leaks out-of-memory ntl