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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:08:27+00:00 2026-05-14T20:08:27+00:00

I have a program that loads a file (anywhere from 10MB to 5GB) a

  • 0

I have a program that loads a file (anywhere from 10MB to 5GB) a chunk at a time (ReadFile), and for each chunk performs a set of mathematical operations (basically calculates the hash).

After calculating the hash, it stores info about the chunk in an STL map (basically <chunkID, hash>) and then writes the chunk itself to another file (WriteFile).

That’s all it does. This program will cause certain PCs to choke and die. The mouse begins to stutter, the task manager takes > 2 min to show, ctrl+alt+del is unresponsive, running programs are slow…. the works.

I’ve done literally everything I can think of to optimize the program, and have triple-checked all objects.

What I’ve done:

  • Tried different (less intensive) hashing algorithms.
  • Switched all allocations to nedmalloc instead of the default new operator
  • Switched from stl::map to unordered_set, found the performance to still be abysmal, so I switched again to Google’s dense_hash_map.
  • Converted all objects to store pointers to objects instead of the objects themselves.
  • Caching all Read and Write operations. Instead of reading a 16k chunk of the file and performing the math on it, I read 4MB into a buffer and read 16k chunks from there instead. Same for all write operations – they are coalesced into 4MB blocks before being written to disk.
  • Run extensive profiling with Visual Studio 2010, AMD Code Analyst, and perfmon.
  • Set the thread priority to THREAD_MODE_BACKGROUND_BEGIN
  • Set the thread priority to THREAD_PRIORITY_IDLE
  • Added a Sleep(100) call after every loop.

Even after all this, the application still results in a system-wide hang on certain machines under certain circumstances.

Perfmon and Process Explorer show minimal CPU usage (with the sleep), no constant reads/writes from disk, few hard pagefaults (and only ~30k pagefaults in the lifetime of the application on a 5GB input file), little virtual memory (never more than 150MB), no leaked handles, no memory leaks.

The machines I’ve tested it on run Windows XP – Windows 7, x86 and x64 versions included. None have less than 2GB RAM, though the problem is always exacerbated under lower memory conditions.

I’m at a loss as to what to do next. I don’t know what’s causing it – I’m torn between CPU or Memory as the culprit. CPU because without the sleep and under different thread priorities the system performances changes noticeably. Memory because there’s a huge difference in how often the issue occurs when using unordered_set vs Google’s dense_hash_map.

What’s really weird? Obviously, the NT kernel design is supposed to prevent this sort of behavior from ever occurring (a user-mode application driving the system to this sort of extreme poor performance!?)….. but when I compile the code and run it on OS X or Linux (it’s fairly standard C++ throughout) it performs excellently even on poor machines with little RAM and weaker CPUs.

What am I supposed to do next? How do I know what the hell it is that Windows is doing behind the scenes that’s killing system performance, when all the indicators are that the application itself isn’t doing anything extreme?

Any advice would be most welcome.

  • 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-14T20:08:28+00:00Added an answer on May 14, 2026 at 8:08 pm

    It turns out that this is a bug in the Visual Studio compiler. Using a different compiler resolves the issue entirely.

    In my case, I installed and used the Intel C++ Compiler and even with all optimizations disabled I did not see the fully-system hang that I was experiencing w/ the Visual Studio 2005 – 2010 compilers on this library.

    I’m not certain as to what is causing the compiler to generate such broken code, but it looks like we’ll be buying a copy of the Intel compiler.

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

Sidebar

Related Questions

I have an ANSI C program that dynamically loads a .so file using dlopen()
Currently i have a program that loads binary data into a stringstream and then
I am working on a program that loads and saves data from text files,
I have a program that reads an XML file (for now, on local computer.)
I have a program with two modes: GUI & Just Run. GUI loads a
I have a bizarre need here, and I am unsure of it's feasibility. I
I'm always referencing DLLs in my C# code, but they have remained somewhat of
Hi this question or problem i have its very hard i have search and
Is there any way to pause all of the bindings on a window, or
I got a question regarding C++ Object & Javascript Object life cycle mis-synchronization and

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.