Skip to content

Fix some memory leaks in libgpuarray#526

Merged
abergeron merged 5 commits intoTheano:masterfrom
notoraptor:fix-memory-leak-libgpuarray
Sep 13, 2017
Merged

Fix some memory leaks in libgpuarray#526
abergeron merged 5 commits intoTheano:masterfrom
notoraptor:fix-memory-leak-libgpuarray

Conversation

@notoraptor
Copy link
Contributor

tot *= newdims[i]
cdims = <size_t *>calloc(nd, sizeof(size_t))
if cdims == NULL:
free(cdims)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cdims is NULL then it can't be allocated. This is useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

cdims[i] = d

array_reshape(res, a, nd, cdims, ord, nocopy)
free(cdims)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole free thing should probably be in a try: .. finally since there could be an exception at basically any point that will take us out of the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abergeron I made a new commit to use try-finally block: 714f3a5

raise GpuArrayException, "..."
cdims[i] = d
try:
cdef size_t d
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to stay outside of the try..finally

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@abergeron abergeron merged commit fdf790b into Theano:master Sep 13, 2017
@notoraptor notoraptor deleted the fix-memory-leak-libgpuarray branch September 14, 2017 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants