Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dft fields memory leak #1264

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions python/meep.i
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,13 @@ meep::volume_list *make_volume_list(const meep::volume &v, int c,
template<typename dft_type>
PyObject *_get_dft_array(meep::fields *f, dft_type dft, meep::component c, int num_freq) {
int rank;
size_t dims[3];
size_t dims[3] = {1,1,1};
smartalecH marked this conversation as resolved.
Show resolved Hide resolved
std::complex<double> *dft_arr = f->get_dft_array(dft, c, num_freq, &rank, dims);

if (rank==0 || dft_arr==NULL) // this can happen e.g. if component c vanishes by symmetry
return PyArray_SimpleNew(0, 0, NPY_CDOUBLE);
if (rank==0 || dft_arr==NULL) { // this can happen e.g. if component c vanishes by symmetry
std::complex<double> d[1] = {std::complex<double>(0,0)};
return PyArray_SimpleNewFromData(0, 0, NPY_CDOUBLE, d);
stevengj marked this conversation as resolved.
Show resolved Hide resolved
}

size_t length = 1;
npy_intp *arr_dims = new npy_intp[rank];
Expand Down