Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1107
  • Last Modified:

St9bad_alloc exceptions

I am getting random St9bad_alloc exceptions when trying to create a vector of floats that is sized at 16M (64MB) from many threads. I have gone through a number of tests and system parameters and cannot seem to figure out the cause. At first, the problem was happening quite often, until I noticed the stacksize limit was low low. I changed the stacksize and heapsize to unlimited and tried again. This time, the error occurs much less often. I monitored the system memory being used, and swap is not being used at all, and main memory still has 1.5GB free. Any ideas on what would cause this? Please let me know if you need more information. Thanks for the help!
0
steveo225
Asked:
steveo225
  • 6
  • 5
1 Solution
 
evilrixSenior Software Engineer (Avast)Commented:
>> when trying to create a vector of floats that is sized at 16M (64MB) from many threads.
Many threads one vector or many threads each with it's own vector? How many threads are we talking here? Can you show the code?
0
 
steveo225Author Commented:
The code is too complex to show. There are never more than 5 threads, vectors are not shared between threads (they are local to the thread function), and each thread has no more than 6 of these float vectors.

Thus, there should never be more than 30 float vectors, and if each float vector reached its max size of 64MB, that's a little less than 2GB. The box has 6GB physical memory, and top (on a 0.5 second refresh) never shows the available memory go below 1.5GB.
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> that's a little less than 2GB
Is this a 32 bit or 64 bit platform? A process can only address, at most, 2GB per process on a 32bit machine. Also, you have to take into consideration memory fragmentation. You have have free memory but you a big enough contiguous chunk to allocate for the processes needs.
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
steveo225Author Commented:
64 bit machine, so addressing is not an issue. Fragmentation should not be an issue, because each buffer is 64MB but over 1.5GB is available. The app itself only ever uses 52% of the available 6GB memory. No other apps are running (aside from standard linux components).  This problem is hurting my brain.
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> 64 bit machine, so addressing is not an issue.
Ok, are you sure your kernel supports 64bit addressing? Have you tried writing a small program that tries to allocate > 2GB? If this works modify it to > 4GB. Does that also work?
0
 
steveo225Author Commented:
Yes, in fact, the application in question uses 3.1GB at one point. I have run tests where the system was using all 6GB physical memory and ~1GB swap without issue.

You bring up an interesting point though, perhaps the app in question is not being compiled as a 64-bit app. I am not sure how to test that thought though. Is there a tool that can tell you if an application is 32 or 64 bit?
0
 
evilrixSenior Software Engineer (Avast)Commented:
>>  I am not sure how to test that thought though. Is there a tool that can tell you if an application is 32 or 64 bit?
You can just use the file command.

$file someProg
someProg: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped
0
 
steveo225Author Commented:
That's it. It is being compiled as 32-bit rather than 64-bit. Now I just have to figure out why. Thanks a ton!
0
 
evilrixSenior Software Engineer (Avast)Commented:
Heh, No worries :)
0
 
evilrixSenior Software Engineer (Avast)Commented:
>> Now I just have to figure out why
Make sure you have 64bit binutils installed.
http://sourceware.org/binutils/
0
 
steveo225Author Commented:
I think it is a compiler issue, using the intel c compiler on AMD hardware, or just missing a flag
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now