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

Empty collections allocate a surprising amount #65

Open
andrewhickman opened this issue Feb 5, 2019 · 1 comment
Open

Empty collections allocate a surprising amount #65

andrewhickman opened this issue Feb 5, 2019 · 1 comment

Comments

@andrewhickman
Copy link

In the standard library, the only collection that allocates when you call new() is VecDeque, which will allocate space for 7 elements.

By comparison, the collections in this library allocate a lot more. Using an element type of u64 for testing:

  • HashSet (and HashMap) will allocate a small amount for the hasher (which is typically a 0-size or Copy type) and 536 bytes of space
  • OrdSet allocates 1080 bytes
  • Vector allocates 544 bytes

I'm not sure if this is easily fixable without a performance penalty but it would be nice to not allocate at all.

@bodil
Copy link
Owner

bodil commented Feb 8, 2019

It would be nice, but I share your concern about a performance penalty - I'd rather waste memory than cycles, tbh. It might be a negligible hit, though - I'll try it and see.

bodil added a commit that referenced this issue Feb 28, 2019
bodil added a commit that referenced this issue Feb 28, 2019
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

No branches or pull requests

2 participants