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 7020481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:19:29+00:00 2026-05-27T23:19:29+00:00

I ran a profiler (very sleepy) on my program and it shows a high

  • 0

I ran a profiler (very sleepy) on my program and it shows a high percentage on my reset function (the reset function runs per-frame).
The programs looks like this:

Init Section:

std::vector<std::vector<int>> VecOfVecOfPath;
VecOfVecOfPath.resize(20); 
for(int i=0; i<20; i++) VecOfVecOfPath.reserve(640);

VecOfVecOfPath is a series of path found by other functions.
VecOfVecOfPath[i] will be filled during execution, per-frame.
E.g. It is push_back-ed by other functions, and reset before using, per-frame.

The reset function:

void Reset()
{
for(int i=0; i<20; i++) VecOfVecOfPath[i].clear();
}

So the reset is very simple, but it do have a pretty high ranking in profiler.

Is this common? Does vector::clear() do have such overheads even for built-in type vectors?

Thanks!


I tried build the program in Release mode and then the cost reduced to almost zero.
From 12~13% to 0.03~0.04%.

Then I went to the source code of and there are defines like ITERATOR_DEBUG_LEVEL effecting extra operations in Debug mode.

So it is like @noggin182 suggested, things are different in Debug and Release mode.

Quote: “Meke sure you are profiling in release build and search to see if there are any preprocessor conditional defines you set to boost performance. – noggin182 Jan 3 at 15:32”

  • 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-27T23:19:29+00:00Added an answer on May 27, 2026 at 11:19 pm

    It depends on what is in your vector, if your nested vectors contain classes then you will be invoking the d’tor for each instance in the nested vectors. I’m quite sure it will also be deallocating memory.

    It sounds like you are writing a game? If so a few books (PDFs) I’ve read on game writing suggest that vector is good for general use but you will be better off NOT using it for games. Just use native arrays and manage the memory yourself or roll your own container class.

    Is 640 the upper-bound of your vector? Would you be better of perhaps using something like this?

    sometype Values[20][640];
    int size[20];
    

    Then your reset call could just be

    for(int i=0; i<20; i++) size[0] = 0;
    

    You will still even be able to use any stl functions like this:

    std::sort(Values[i], Values[i] + size[i]);
    

    That’s about as much help as I can provide without any more information

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

Sidebar

Related Questions

I ran the profiler in firebug and found that the most time costly function
I ran ruby-profiler on one of my programs. I'm trying to figure out what
When I ran the profiler on a JQuery intensive page while tuning for performance,
I ran my code through xdebug profiler and saw more than 30 percent of
I ran into an interesting (and very frustrating) issue with the equals() method today
I ran SQL Server Profiler trace (duration on batch complete) and found one really
EDIT: I ran the python profiler and the two most time-consuming things (this is
What does a Profiler do exactly? I ran the JProbe profiler on my Java
Ran across this line of code: FormsAuth = formsAuth ?? new FormsAuthenticationWrapper(); What do
Ran into an Out of Stack Space error trying to serialize an ASP.Net AJAX

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.