-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
sizeof reports wrong size for array of non-power-of-2 primitive types #35884
Comments
Yeah sounds like we're not aligning the data when making the array:
|
Are you sure?
This looks aligned to me. Maybe it is just |
I suspect we might not have asked malloc for the right size also in that case |
I think it is better to clarify what the |
It looks like a bug in codegen for |
This grew out of a discussion on Slack about the size taken by arrays of
BitIntegers
, but basically it seems thatsummarysize
will return the bytes Julia thinks the object takes in memory by just adding up the size of the array elements without regard for their actual alignment on chip.Setup (this is actually independent of the BitIntegers package, and is true for any type created using a primitive type):
Results:
However, on chip the size taken by each element in the array is:
So
summarysize
isn't actually reporting the size on chip, it is reporting the size according to the number of bytes that Julia used to create it since it just callsCore.sizeof
on the type:julia/base/summarysize.jl
Line 115 in 1b6101a
The main question is, what should "memory" refer to in the documentation for
summarysize
? Should there be a different exposed function to actually get the on-chip memory usage?The text was updated successfully, but these errors were encountered: