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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:37:24+00:00 2026-05-18T02:37:24+00:00

In my application I save voxel-data (compressed byte array) and trying to load it

  • 0

In my application I save voxel-data (compressed byte array) and trying to load it back again into memory.

But my application crashes in Windows 7 machine (64 bit ,12 GB) giving bad_alloc .

This works fine on Linux ,and even runs on some other Windows 7 machine with 4 GB memory.

Compressed bye size is about 200Mb and uncompressed byte size is about 300Mb.(so only 500 MB reserved before this ‘new’ statement,which leaves almost 8 GB excluding system memory ). I don’t run any other major memory allocation steps before this ,so I don’t think memory is fragmented.
I use MinGW GCC version 4.5.0

Any tips on this ?

thanks in advance.

QFile fileVol(strVFile);

//Read VolumeData
fileVol.open(QIODevice::ReadOnly);
QDataStream volstream(&fileVol);
QByteArray volCmprsdByteArray;     //This holds the compressed byte array

//Read some additional information
int nx, ny, nz, bbp;
int voltype;
volstream >> nx;
volstream >> ny;
volstream >> nz;
volstream >> bbp;
volstream >> voltype;
volstream >> volCmprsdByteArray;     //read our compressed voxel-data

//we have original uncompressed pixel data
QByteArray volUncmprsdByeArray = qUncompress(volCmprsdByteArray);

int uncompressedSize = volUncmprsdByeArray.size(); // size of the byte array
qDebug("new char for uncompressed data size %d",uncompressedSize);

unsigned char* volumeData=NULL;

//Trying to allocate new memory 
try {
    // ##### breaks here.   ####
    volumeData =new unsigned char[uncompressedSize];   
 }
catch (std::bad_alloc e)
 {
      cout << "lu_solver() bad_alloc: " << e.what() << endl;
      cout << "Size " << uncompressedSize << endl;
      //return;
}
  • 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-18T02:37:25+00:00Added an answer on May 18, 2026 at 2:37 am

    If you are building the program as a 32-bit binary on Windows, you only get 2GB of available address space (the upper half is reserved).

    When you consider that the address space can be fragmented by lots of different things being allocated (DLLs getting loaded, thread stacks, dynamic allocation), it’s likely that you’ll end up having large allocations fail very quickly.

    You can try giving the linker the /LARGEADDRESSAWARE flag, which will give you a 3GB address space on correctly configured 32-bit Windows and the full 4GB address space on 64-bit Windows. Really, though, it’s a good idea to find a way to reimplement your program so that you can use several smaller allocations instead of one huge one.

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

Sidebar

Related Questions

I'm trying to implement a Load / Save function for a Windows Forms application.
in vb.net i am trying to save application settings but for USER but i
In my application I save some data related to the users sessions in the
I have an application which save datetime using Time.now, but when I retrieves it
I have a problem in a Windows Forms application with Bitmap.Save failing when I
I need to save a user's login information in encrypted form for this application
I am writing an iPhone application, and need to save the state of my
Application able to record error in OnError, but we are not able to do
I am writing an application to save the captured IP packets to file. Which
I'm using a WCF application to save a file received via streaming to the

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.