-
Notifications
You must be signed in to change notification settings - Fork 5
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
Memory allocation associated with reshape if no explicit indexing occurs. #5
Comments
Hm, I wonder if this could be a benchmarking artifact. But in any case, the second version is not only "unsafe", but very dangerous: You're allowing the unsafe array to escape from the |
Thank you so much for the quick response, and pointing out the danger in my function code. Based on your guidance I believe I resolved the issue.
Returning nothing explicitly appears to eliminate the extra memory allocation. |
Happy to help!
|
The following piece of code behaves as you may expect, with zero allocations occurring:
However, if you eliminate the indexing event, then an allocation appears:
This seems like undesirable behavior. It doesn't make sense that eliminating the line s[1]=1 would introduce a memory allocation when before there was not one.
Let me know what you think! I am confused by this behavior...
The text was updated successfully, but these errors were encountered: