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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:39:13+00:00 2026-06-03T01:39:13+00:00

I have C implementation of an algorithm that includes shared library. The performance of

  • 0

I have C implementation of an algorithm that includes shared library. The performance of the shared library is considerably different in C and C++ (performing much better in C++). Therefore, I have changed the shared library parts of the C implementation (Imp-1) into C++ (Imp-2) while keeping the rest of it same. I have compiled Imp-1 and Imp-2 by using gcc and g++ in Linux, respectively. In small sized problems both Imp-1 and Imp-2 perform exactly same. However, in a same large sized problem while Imp-1 solves it without any problem, Imp-2 returns std::bad_alloc error. Interestingly, this error occurs when the memory usage increases to 4GB where the available memory is 35GB.

Why this error occurs? (Compiler, operating system, compiler option, etc.)

Best Regards.

  • 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-03T01:39:14+00:00Added an answer on June 3, 2026 at 1:39 am

    It seems that your gcc is a 64 bit compiler where as g++ is a 32 bit compiler. Even if you are running on a 32 bit system, unless you compile your program with a 64 bit compiler, your program cannot fully leverage the 64 bit addressing capabilities which would result a bad_alloc as you are experiencing if you want to address more than 4GB.

    The reason I am confident that you are running a 32 bit compiled program on a 64 bit is the 4GB limit. Generally speaking, the memory is split as User/Kernal Space and on a 32 bit system the entire 4GB is not available, usually it is between 2GB and 3GB. As you can address the entire 4GB it seems you are running a 32 bit program on a 64 bit environment.

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

Sidebar

Related Questions

I have written 2 implementation of bubble sort algorithm in C and Haskell. Haskell
I know that it's OK for a pure virtual function to have an implementation.
I have an algorithm that uses the following OpenSSL calls: HMAC_update() / HMAC_final() //
I believe that out there we have algorithms implementations (e.g. a c++ implementation of
I have an algorithm that calculates the percentile(85) with Apache Commons of a series
I know that A* algorithm implementation problems are relatively common on stackoverflow (I've been
I have a design for a GC algorithm that I would like to implement
I downloaded the JSON2.js from https://github.com/douglascrockford/JSON-js/blob/master/json2.js and it does not have implementation for JSON2.stringify()
I have an implementation of a DefaultTableCellRenderer. When someone selects a row in the
I have STI implementation as follows: class Automobile < ActiveRecord::Base end class Car <

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.