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

  • Home
  • SEARCH
  • 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 6864637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:56:11+00:00 2026-05-27T02:56:11+00:00

Wondering why my memory accesses were somewhat slower than I expected, I finally figured

  • 0

Wondering why my memory accesses were somewhat slower than I expected, I finally figured out that the Visual C++ implementation of deque indeed has an extra layer of indirection built-in, destroying my memory locality.

i.e. it seems to hold an array of T*, not an array of T.

Is there another implementation I can use with VC++ that doesn’t have this “feature”, or is there some way (although I consider it unlikely) to be able to avoid it in this implementation?

I’m basically looking for a vector that has also O(1) push/pop at the front.
I guess I could implement it myself, but dealing with allocators and such is a pain and it would take a while to get it right, so I’d rather use something previously written/tested if possible.

  • 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-05-27T02:56:12+00:00Added an answer on May 27, 2026 at 2:56 am

    For whatever reason, at least as of MSVC 2010, the std::deque implementation appears to make use of an unbelievably small block size (the max of 16 bytes or 1 single element if I’m not mistaken!).

    This, in my experience, can result in very significant performance issues, because essentially each “block” in the data structure only ends up storing a single element, which leads to all kinds of additional overhead (time and memory).

    I don’t know why it’s done this way. As far as I understand it setting up a deque with such a small block size is exactly how it’s not supposed to be done.

    Check out the gcc stdlib implementation. From memory they use a much larger block size.

    EDIT: In an attempt to address the other issues:

    • std::deque should have an extra layer of indirection. It is often implemented as a “blocked” data structure – i.e. storing an array of “nodes” where each node is itself an array of data elements. It’s not ever like a linked-list – the array of nodes is never “traversed” like a list, it’s always directly indexed (even in the case of 1 element per block).

    • Of course you can roll your own data structure that keeps some extra space at the front. It wont have worst case O(1) push/pop front/back behaviour, and as such it wont satisfy the requirements of the std::deque container. But if you don’t care about any of that…

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

Sidebar

Related Questions

I am wondering is there a way to find out memory allocations that dont
I am basically wondering how C++ lays out the object in memory. So, I
I was just wondering how exactly memory works such that a language standard (such
I'm wondering, what are good practices for dealing with out of memory errors. void
I was wondering how much memory does an object that inherits from object and
I was wondering as to the practicalities of storing an in memory tree structure
I had been wondering for quite some time on how to manager memory in
I was playing around with memory-mapped files in C and was wondering if there
I'm wondering what are the recommended ways to handle situations where, in memory managed
I am wondering , what exactly is stored in the memory when we say

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.