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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T17:08:10+00:00 2026-06-05T17:08:10+00:00

I am running this code: #include <iostream> #include <cstddef> int main(int argc, char *argv[]){

  • 0

I am running this code:

#include <iostream>
#include <cstddef>


int main(int argc, char *argv[]){
    int a1=0, a2=0;
    int a3,a4;

    int b1=++a1;
    int b2=a2++;

    int*p1=&a1;
    int*p2=&++a1;

    size_t st;
    ptrdiff_t pt;

    int i=0;
    while(true){
        printf("i: %d",i++);
    }
    printf("\n\ni now is: %d\n",i);
    return 0;
}

why do I observe such decrease in image memory (fiolet):
enter image description here
legend:

enter image description here
I made this general Win32 project, not CLR.
I changed the code, so I will see when int has become finally negative. Now the while() is:

    int i=0;
    while(0<++i){
        printf("i: %d",i++);
    }
    printf("\n\ni now is: %d\n",i);

It is strange: please see what happend after just 30000 iterations. Why do we see these fluctuations in the image memory? I can see now that probably this is involved with VMMap itself, because it happens only if I choose “launch & trace a new process” but not when “view a running process” and point to running exe fired from VS2010. Here is the screen of process “launched & traced”:
enter image description here

I observed also huge paging of memory, which started roughly with this decline in image (this paging nearly accelerated and quickly triggered RAM limit, that I have set to 2GB):
enter image description here
and here is a running process only “viewed” (runned from VS2010):
enter image description here

so maybe some issue subject to memory management of the .NET applications takes place here?
I am still waiting for my int to cross boundary of two complement.

well… I have to edit again: it turns out that as previously thought – the decreasing memory image effect is present when process is only viewed (not launched) too. Below is attached picture of the same process 10 minutes later (still waiting for turning int into negative):
enter image description here

and here it is:

enter image description here

so the biggest positive 2-complement on my machine is 2 147 483 647
and smallest negative is -2 147 483 648, what is easy to verify this way:

#include <limits>
const int min_int = std::numeric_limits<int>::min();
const int max_int = std::numeric_limits<int>::max();

it gave me the same result: -2 147 483 648 and 2 147 483 647

back to the beginning
when I comment everything but the while() loop – the same thing happens: image is decreasing after process was running about 10 minutes, so it is not the useless code that cause this. but what?

  • 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-05T17:08:14+00:00Added an answer on June 5, 2026 at 5:08 pm

    Working set is largely under control of the operating system. What your code does is only one factor it considers when deciding whether to grow or trim your working set. Other factors include whether your application is in the foreground, how active it is, how greedy the heap algorithm is, how much memory pressure exists because of the demands of other processes, etc. This is by design.

    The drops are probably related to Windows choosing to trim your working set. Since most of the code that was originally loaded was probably just for initialization and is not involved in the loop, it was simple for the OS to reclaim image pages based on a LRU-algorithm.

    Notice that the working set allocated to the image size is not the only portion that was trimmed.

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

Sidebar

Related Questions

Running this code: #include <string> #include <iostream> using namespace std; int main() { string
There is this code: test2.cpp (compiled to test2 executable): #include <iostream> int main(int argc,
This is my code: #include <iostream> #include <fstream> using namespace std; int main() {
Have a look at this code: #include <iostream> using namespace std; int main() {
I have the following code #include <iostream> #include <vector> using namespace std; int distance(vector<int>&
I get a segmentation fault when running this code. Anyone know why? Thanks. #include
While I am running this code it showing me a following error:- Column 'virtuemart_product_id'
Why can't I get anything to display with this code? #include <iostream> #include GL/glfw.h
I came across a strange phenomena upon running the following code: #include <iostream> class
My code is simply as this: UPDATED : #include <iostream> #include <fstream> using namespace

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.