-1

My Visual Studio C++ 2008 project builds the executable in 32 bit platform, in both debug and release modes, without any issue and executable runs and generates expected results.

I have some matrices with the size of more than 26000 rows by 26000 columns (double type) and in 32 bit platform I can not allocate memory to this matrices. Therefore I have to switch to 64 bit platform.

On 64 bit platform I can build my executable without any error (both debug and release modes) but when trying to run the executable I receive the following message in debug mode:

enter image description here

And the following message in release mode:

enter image description here

I stepped through the code in debugging mode and the first message I receive is this (which occurs at Microsoft COM):

enter image description here

Every time I click on continue on the previous message, I get a different error message occurring at different locations of a file named STAADLibBentley.tli like the two ones shown below as a sample:

enter image description here enter image description here

At the top of the STAADLibBentley.tli the following comments are written, which shows the TLB file is for Win32 and the compiler is implementing a wrapper for TLB file to use it in 64 bit platform.

enter image description here

Looks like this STAADLibBentley.tli file is a wrapper implemented automatically by the compiler, related to STAADLibBentley.tlb file which I'm using in my C++ code like below and is related to STAAD APIs, STAAD is a software with which I'm communicating by TLB libraries. I'm using the TLB file like this:

enter image description here

Now the question is, if the compiler is taking care of writing a wrapper for the Win32 TLB file to use it in 64 platform, why I'm receiving those error messages mentioned above inside STAADLibBentley.tli file. Does anybody know what is the possible reason?

Megidd
  • 7,089
  • 6
  • 65
  • 142
  • 1
    `(26000 * 26000 * sizeof(double)) / (1024 * 1024 * 1024) = 5GB`. You cannot allocate that much. I very much doubt you can. I run a 64-bit system with 32GB ram and I can still only allocate 4GB at any given instance. I don't think the computer can find more than 4GB contiguously.. OR there is a limit. – Brandon Oct 03 '14 at 20:51
  • @Brandon I'm wondering how one can handle large matrices. Any option? – Megidd Oct 03 '14 at 21:01
  • 1
    Well.. I used the no-throw version of new just now and was able to allocate 21GB contiguously but lagged like hell! I was following this post: http://stackoverflow.com/questions/17952731/allocating-more-than-4gb-memory-in-a-64-bit-system Without the no-throw, it threw `std::bad_alloc` at 4GB.. I guess you can either use no-throw OR just allocate in REASONABLE chunks rather than trying to allocate all 5GBs at once.. Maybe allocate 100mb - 500mb at a time and keep track of it. Not every computer has huge amounts ram. Not sure that this solution will be good for matrices though.. – Brandon Oct 03 '14 at 21:04
  • 1
    The error doesn't seem to be `bad_alloc` - are we sure that the code is actually operating correctly in general? Do you get the same problem if you use a much smaller size? – Mats Petersson Oct 03 '14 at 21:48
  • 1
    Also, is it possible that the code contains "hard-coded sizes", such as using `4` instead of `sizeof(*int)`? – Mats Petersson Oct 03 '14 at 21:50
  • @Brandon In the 32 bit version of my C++ code, when I want to allocate the 26000x26000 matrix, I get the same `std::bad_alloc` error as you get without the no-throw. For small matrices, the 32 bit version of C++ code works good. – Megidd Oct 05 '14 at 15:31
  • @MatsPetersson In the 32 bit version of my C++ code, when I want to allocate the 26000x26000 matrix, I get the `std::bad_alloc` error. But or small matrices, the 32 bit version of C++ code works good. – Megidd Oct 05 '14 at 15:34
  • 1
    Right, your current error is not bad_alloc, but appears to be a memory corruption type error, which made me think that something might be writing out-of-bounds. – Mats Petersson Oct 06 '14 at 07:44

1 Answers1

0

I talked to people familiar with API of STAAD software, I was told that the API is a component of 32 bit Microsoft COM not 64 bit. Fortunately, there are some tricks to use 32 bit COM in 64 bit platform like the following links, I may give it a try:

http://www.gfi.com/blog/32bit-object-64bit-environment/

Getting the GUID of an installed COM object

Community
  • 1
  • 1
Megidd
  • 7,089
  • 6
  • 65
  • 142