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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:54:33+00:00 2026-06-05T15:54:33+00:00

#include <iostream> #include <cassert> #include <vector> #include <ctime> #include <cstdlib> #include <Windows.h> using namespace

  • 0
#include <iostream>
#include <cassert>
#include <vector>
#include <ctime>
#include <cstdlib>
#include <Windows.h>

using namespace std;

char randomLetter()
{
    srand(time(0));
    char rValue;

    while(1)
    if((rValue=(rand()/129)) > 31) 
        return rValue;
}


int main()
{       
    vector<char> meegaString;

    for(int i=0; i < 10000000000; i++)
    {   
        meegaString.push_back(randomLetter());

                if(!(i%10000000)) 
            cout<<"There are: " <<i+1<<" chars in the list"<<endl;

    }

    system("pause");
    return 0;
}

RAM usage before running this program was approximately 2500/8000 MB.
When it comes to 3200, the following exception is thrown:

Unhandled exception at 0x773c15de in Resources gormandizer.exe:
Microsoft C++ exception: std::bad_alloc at memory location
0x0045f864..

1) Why this program didn’t fill the whole available memory , although it was working on a 64 bit OS?

2) Why only 26 percent of processor(intel core i5) were in usage?

  • 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-05T15:54:35+00:00Added an answer on June 5, 2026 at 3:54 pm
    1. As noted, the elements of a vector are stored contiguously. Also, depending on the memory allocation algorithm used in your implementation of std::vector, it is probably attempting to pre-allocate memory ahead of time; allocating more memory than is being used to cut down on the number of malloc/new calls. As such, it might be getting to the point where it’s requesting more memory than a 32-bit OS can support (which would explain why a 64-bit process would work, but a 32-bit process wouldn’t, despite having enough memory available).

    2. Your process is running on one core out of 4, and it’s quite busy, hence it’s taking up approximately 25% of the CPU time. Other processes would make up the rest.

    See also: Being Smart About Vector Memory Allocation

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

Sidebar

Related Questions

#include <iostream> #include <string> #include <vector> using namespace std; struct Exmpl{ Exmpl() { cout
#include<iostream> #include<cstdio> using namespace std; int main() { int T; char J[100], S[100]; int
#include <iostream> #include <string.h> using namespace std; void newBuffer(char* outBuffer, size_t sz) { outBuffer
#include <iostream> using namespace std; // This first class contains a vector and a
#include <iostream> #include <string.h> #include <iomanip> #include <cstring> #include <cassert> using namespace std; #ifndef
#include iostream #include vector using namespace std; const vector<int>& Getv() { vector<int> w(10); w[0]=10;
#include iostream #include conio.h #include exception #include cstdlib using namespace std; void myunexpected ()
#include<iostream> using namespace std; class StudentClass{ friend class Oopclass; public: StudentClass(); void setStudentData(); void
#include <iostream> using namespace std; class B { public: int getMsg(int i) { return
#include <iostream> using namespace std; class boiler { private: static boiler uniqueInstance; bool boilerEmpty;

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.