| | |
Trouble finding enough RAM for malloc() in Vista 64?
Thread Solved
![]() |
•
•
Join Date: Dec 2004
Posts: 42
Reputation:
Solved Threads: 0
I'm having a lot of trouble finding enough RAM for a program I'm writing on Vista 64 Ultimate system, even though the system has 8GB RAM and only 2GB is used.
I tried to see how many 10 million byte blocks I could allocate using malloc(), and the compiled program crashes after the 209th block. So it crashes after just around 1.94GB of total memory allocated, despite the system having multiple more gigs of RAM available.
I don't know if the issue has to do with contiguous RAM or what. The same test program doesn't segmentation fault on a Linux system until after the 320th block, which should be because it's hitting the 3GB kernel limit for a process.
I've tried using various compilers, including the command line compiler for Visual Studio 2008, which I assume is a 64 bit compiler.
The actual program I'm working on needs a ton of memory for memory mapping data files about 800MB in size, and malloc() large arrays of the same size for numerical calculations. I actually moved from Linux to Windows because it was 64 bit with 8GB of memory.
What can I do to be able to use more RAM with malloc()?
I tried to see how many 10 million byte blocks I could allocate using malloc(), and the compiled program crashes after the 209th block. So it crashes after just around 1.94GB of total memory allocated, despite the system having multiple more gigs of RAM available.
I don't know if the issue has to do with contiguous RAM or what. The same test program doesn't segmentation fault on a Linux system until after the 320th block, which should be because it's hitting the 3GB kernel limit for a process.
I've tried using various compilers, including the command line compiler for Visual Studio 2008, which I assume is a 64 bit compiler.
The actual program I'm working on needs a ton of memory for memory mapping data files about 800MB in size, and malloc() large arrays of the same size for numerical calculations. I actually moved from Linux to Windows because it was 64 bit with 8GB of memory.
What can I do to be able to use more RAM with malloc()?
>>Visual Studio 2008, which I assume is a 64 bit compiler.
No -- its a 32-bit compiler. But the Pro version can compile 64-bit code if you provide the right options. Just because you compile something on a 64-bit os doesn't mean you will automatically get a 64-bit program.
Post a short example program that produces the problem you are talking about.
No -- its a 32-bit compiler. But the Pro version can compile 64-bit code if you provide the right options. Just because you compile something on a 64-bit os doesn't mean you will automatically get a 64-bit program.
Post a short example program that produces the problem you are talking about.
I just tested a short program and it stopped at about 2Gig just as you had also reported. I believe the reason is a 32-bit program can only access 2 Gig RAM.
To get the 64-bit version of VC++ 2008 you have to select an option during installation. Here is how to do it.
To get the 64-bit version of VC++ 2008 you have to select an option during installation. Here is how to do it.
•
•
Join Date: Dec 2004
Posts: 42
Reputation:
Solved Threads: 0
(edit: whoops, you posted as I was reading that vcvarsall stuff
I'll check out that link)
Thanks. The version I have is the Professional Edition. How do I use the 64-bit compiler? Do I change a setting somehow and use 'cl', or is there a flag to pass? I read How to: Enable a 64-Bit Visual C++ Toolset at the Command Line but didn't get how to actually use vcvarsall.bat.
Here's the code for my test program. It tries to allocate lots of arrays, and then assign a value to an element of the array (it's the assignment that causes the crash). The program crashes on my PC after the test207-test209, varying on different executions (not sure what that indicates). On Linux it seg faults after 320.
I'll check out that link)Thanks. The version I have is the Professional Edition. How do I use the 64-bit compiler? Do I change a setting somehow and use 'cl', or is there a flag to pass? I read How to: Enable a 64-Bit Visual C++ Toolset at the Command Line but didn't get how to actually use vcvarsall.bat.
Here's the code for my test program. It tries to allocate lots of arrays, and then assign a value to an element of the array (it's the assignment that causes the crash). The program crashes on my PC after the test207-test209, varying on different executions (not sure what that indicates). On Linux it seg faults after 320.
C++ Syntax (Toggle Plain Text)
#include <iostream> using namespace std; int main(int argc, char *argv[]){ double* test1 = (double*) malloc(10000000); test1[0] = 1.0; cout<<"Done 1"<<endl; double* test2 = (double*) malloc(10000000); test2[0] = 1.0; cout<<"Done 2"<<endl; double* test3 = (double*) malloc(10000000); test3[0] = 1.0; cout<<"Done 3"<<endl; ... double* test398 = (double*) malloc(10000000); test398[0] = 1.0; cout<<"Done 398"<<endl; double* test399 = (double*) malloc(10000000); test399[0] = 1.0; cout<<"Done 399"<<endl; double* test400 = (double*) malloc(10000000); test400[0] = 1.0; cout<<"Done 400"<<endl; }
Last edited by Kadence; Jul 5th, 2009 at 1:54 am.
I don't know how to enable 64-bit. From what I see in the link I posted, and read in other places, its enabled during installation of the compiler. There is apparently an installation option that lets you install the 64-bit compiler. You may have to reinstall the compiler in order to get it.
Last edited by Ancient Dragon; Jul 5th, 2009 at 2:06 am.
All my Windows work is still under Win32.
Remember in 32-bit land you only have about 3.2Gig totally available to your application, which really works out to about 2Gig because Dev Studio is an oinker! It's a memory hog! Especially in a debug build.
You're using C++ compilers and using C memory allocation!
You should be using new/delete new[]/delete[]. Not Malloc Free.
For fun try GlobalAlloc(), under Vista 64. see how much it lets you allocate!
Remember in 32-bit land you only have about 3.2Gig totally available to your application, which really works out to about 2Gig because Dev Studio is an oinker! It's a memory hog! Especially in a debug build.
You're using C++ compilers and using C memory allocation!
You should be using new/delete new[]/delete[]. Not Malloc Free.
For fun try GlobalAlloc(), under Vista 64. see how much it lets you allocate!
Sorry I meant Visual Studio. (Dev Studio is a nickname for it!)
And Windows swaps out memory as you say, but DevStudio is the memory hog. Windows gives memory to the more active application and Visual Studio is a memory hog when it runs. Totally Shut down Visual Studio and run your test again as a standalone application.
Better yet, Reboot, then run your program and check your numbers!
And Windows swaps out memory as you say, but DevStudio is the memory hog. Windows gives memory to the more active application and Visual Studio is a memory hog when it runs. Totally Shut down Visual Studio and run your test again as a standalone application.
Better yet, Reboot, then run your program and check your numbers!
•
•
Join Date: Jul 2009
Posts: 3
Reputation:
Solved Threads: 2
Seven Steps of Migrating a Program to a 64-bit System
Abstract. The article describes the main steps which should be performed to correctly port 32-bit Windows applications on 64-bit Windows systems. Although the article is meant for developers using C/C++ in Visual Studio 2005/2008 environment, it will be also useful for other developers who plan to port their applications on 64-bit systems.
Abstract. The article describes the main steps which should be performed to correctly port 32-bit Windows applications on 64-bit Windows systems. Although the article is meant for developers using C/C++ in Visual Studio 2005/2008 environment, it will be also useful for other developers who plan to port their applications on 64-bit systems.
![]() |
Similar Threads
- My vista is afraid of speed (Windows NT / 2000 / XP)
- Maximizing 4gb ram on a Windows Vista 32bit (Windows Vista and Windows 7)
- Dell RAM Upgrade Q's -- Size, Compatibility, Installation. (Motherboards, CPUs and RAM)
- 8GB of RAM on Windows Vista 64x (Windows NT / 2000 / XP)
- Vista Installation Nightmare- UPDATE!! (Windows Vista and Windows 7)
- Demo RAM/GFX Card Tutorial (Motherboards, CPUs and RAM)
- ram on vista (Windows Vista and Windows 7)
- Barton vs Thoroughbred core (Motherboards, CPUs and RAM)
Other Threads in the C++ Forum
- Previous Thread: Completely Stuck on class project-- HELP!
- Next Thread: application decision program help
| Thread Tools | Search this Thread |
addition api array base based binary bitmap c++ c/c++ char class classes code coding compile console conversion count delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email embed encryption error erroraftercompilation excel file forms fstream function functions game getline givemetehcodez gmail graph gui homework homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker loop looping loops map math matrix matrix3d memory multiple news node output parameter pointer problem program programming project python random read recursion reference rpg std::coutwstring string strings temperature template test text text-file tree url variable vector video visualization win32 windows winsock word wordfrequency wxwidgets






