Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9259293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:37:17+00:00 2026-06-18T12:37:17+00:00

I was wondering just exactly how much more memory the queue uses in comparison

  • 0

I was wondering just exactly how much more memory the queue uses in comparison to the vector. I was having an issue the other day where I had an array of int queues that used around 60MB and when the same data was put in a vector of vectors it used around 4MB. Is this an error on my part in coding the program or do stl queues generally use more memory than vectors?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:37:18+00:00Added an answer on June 18, 2026 at 12:37 pm

    The std::queue is a container adaptor, not a container itself. So let’s compare the overhead of some actual containers:

    • std::vector is very memory-efficient, it uses almost zero overhead. A std::vector<int> uses about 4 bytes per item, on most platforms.

    • std::list is very inefficient with memory, it will likely use two pointers of overhead per item. A std::list<int> uses about 24 bytes per item, on 64-bit platforms, and 12 bytes on 32-bit platforms.

    • std::deque is between the two, and it is the default container for std::queue. According to “what the heck is going on with the memory overhead of std::deque“, the MSVC deque is a list of blocks each containing around 16 bytes, which is quite a bit of overhead if your queues contain one or two int each and you have a lot of queues.

    Another factor that affects overhead is the efficiency of the allocator on your platform, which will color your results unless you can account for it. A 15x difference between two implementations is so large it’s downright suspicious — it makes me wonder how you got those numbers.

    In general, if your queues are very short, there is a lot of room for improvement over the other implementations. If you’re okay with writing your own container, you could write a circular buffer container or use Boost’s circular_buffer. A circular buffer combines the memory efficiency of std::vector with the CPU efficiency of std::deque for deque type operations. Kind of makes me wish it were in the STL to begin with. Oh well.

    Footnote

    The actual amounts of overhead will vary with the implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering this the other day. I am not exactly sure how
I was just wondering how exactly memory works such that a language standard (such
I'm just wondering exactly what factors affect how quickly createthread executes, and how long
I'm just wondering how exactly does a delegate method know when to be called?
Just wondering, having the following simple code: var object1 = { name: function (){
I was just wondering where exactly i could get the javadocs for jboss libraries?
Just wondering why the space is required here.. .load(url + (' #newsItem') How exactly
I was just wondering if it's possible to find exactly what element was clicked
As a complete WinDbg beginner, I am just wondering, what is exactly going into
I'm wondering how exactly to perform a 3-way join using the following structure (much

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.