|
Again it depends on the OS.
In window, usually a process can take only 2GB of memory( User mode ), the remaining 2GB is reserved for Kernal mode.
Again among this 2GB, some memory will be already taken by process, for loading exe, dll, heap, stack etc. So technically, the maximum about of memory that you can specify in malloc is always less than 2GB and the excat value depends on various factors I mentioned above.
I dont know about Linux
|
|
|
|
|
rupeshkp728 wrote: We know that in a 32 bit system a 4 gb memory gets allocated to a process.
It's 2GB unless the /3GB startup switch is used.
rupeshkp728 wrote: So how much maximum memory can be allocated using a malloc function call?
Since it has to be contiguous, no more than 2GB, but realistically it will be less.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Thanks David for the solution
|
|
|
|
|
That's a bit like asking "how long is a piece of string?"
Here's why...
- Every process is given it's own address space to run in. Depending on where the OS and compiler conspire to load your code will determine the largest lump of memory you can allocate
- The OS may allocated loads of other guff which will restrict where the compiler can stick it's heap
- The OS may have extra overheads managing it's heap (e.g. Windows having different heaps for different size ranges of allocation)
- How malloc is implemented on top of the underlying OS can also mess things up
- The computer may not have enough disk space or memory to service your request
So to find out how much you can allocate try it! Do a malloc for INT_MAX bytes and if that fails divide the size by 2 and try again. You can use something a bit more sophisticated but you really need to try it on a particular system with a given compiler and load to see what happens.
Cheers,
Ash
|
|
|
|
|
Thanks Ash for the reply.
I tried malloc with INT_MAX and it indeed fails and with your way we can find out how much exactly the memory can be allocated.
|
|
|
|
|
How hash tables are used to quickly locate a data record?
|
|
|
|
|
|
|
Hi!
When I run my application, it crashes and says "SlogOut3D.exe has triggered a breakpoint". When I break the
Exception, it goes to a file "irrArray.h". It stops at the following line:
const T& operator [](u32 index) const
{
_IRR_DEBUG_BREAK_IF(index>=used)
return data[index];
}
Here is the Call Stack:
> SlogOut3D.exe!irr::core::string<char,irr::core::irrAllocator<char> >::c_str() Line 410 + 0x3 bytes C++
SlogOut3D.exe!CGameMenuPlayerProfileState::fillStructure(const irr::core::array<irr::core::string<char,irr::core::irrAllocator<char> >,irr::core::irrAllocator<irr::core::string<char,irr::core::irrAllocator<char> > > > result={...}, playerData profileData={...}) Line 334 + 0x11 bytes C++
SlogOut3D.exe!CGameMenuPlayerProfileState::GUIEvent(CGameManager * pManager=0x0012fdb4, const irr::SEvent & event={...}) Line 168 C++
SlogOut3D.exe!CGameManager::OnEvent(const irr::SEvent & event={...}) Line 171 + 0x1d bytes C++
Irrlicht.dll!1000dccf()
[Frames below may be incorrect and/or missing, no symbols loaded for Irrlicht.dll]
Irrlicht.dll!10002d28()
Irrlicht.dll!1000e1b6()
Irrlicht.dll!101325ae()
Irrlicht.dll!101333b3()
shimeng.dll!6e374435()
gdi32.dll!776f48d9()
user32.dll!76700979()
opengl32.dll!684e834f()
user32.dll!766ffd72()
user32.dll!766ffe4a()
user32.dll!766ffdf3()
user32.dll!7670018d()
user32.dll!766f8343()
Irrlicht.dll!10134005()
SlogOut3D.exe!main() Line 24 + 0x25 bytes C++
SlogOut3D.exe!__tmainCRTStartup() Line 582 + 0x19 bytes C
SlogOut3D.exe!mainCRTStartup() Line 399 C
kernel32.dll!774ad0e9()
ntdll.dll!77a919bb()
ntdll.dll!77a9198e()
SlogOut3D.exe!btDbvt::update() + 0x104 bytes
89cccccc()
How to clear the exception?
|
|
|
|
|
By not indexing out of the array probably...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Well, the error is pretty clear no ? You are accessing the array outside of the bounds. So, to avoid the exception, simply do not go outside the boundary of the array.
|
|
|
|
|
It's not so much an exception but a hard coded breakpoint the programmers of your array class put in the library to stop you doing something that might crash the program, or at least tell you before a customer gets hold of it.
Check that the array is the correct size for the number of things you're sticking in it and if not resize it appropriately.
|
|
|
|
|
|
You should wrap the LoadString WINAPI [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
What do you mean exactly ? Could you provide some code snippet ?
|
|
|
|
|
Hi!
I've one string array.It's declared as follows:
irr::core::array<irr::core::stringc> result;
Here is my Structure:
struct playerData
{
int id,matches,innings,notouts,runs,highest,hundred,fifty,catches,strikerate,balls,runs_given,wickets,fivewkt;
char bestbowling[32];
};
I've to Copy the Array elements to Structure elements. How to do this?
|
|
|
|
|
You will need to assign each member individually (I guess you want to store each string in the id, matches, innings, ... mebers). Furthermore, you have to convert your different string to integer.
|
|
|
|
|
I think you are underestimating the power of your brain. You will learn more if you figure out things like that for yourself.
struct
{
int a;
} s;
int arr[10];
s.a = arr[0];
|
|
|
|
|
Hi sir,
I have deleloped one dialog based application,where
I will enter username and password
and i have a created a button(Save).
my plan is when i click the button i wnat it to save it in a database.
I have created a database
I have used this steps
In SQL Server Enterprise MAnager
I have created a new database as "Sample"
and also created a new table there and two columns as "Name" and Password.
Now i am not getting how can i connect to database
I am totally struct and messing around,please give me any idea how can i process.
Thanks
Raj
|
|
|
|
|
|
if your's application is MFC based application, CDatabase class is there for manipulate database. If you wanna manipulate your database, you should make following steps..
1. Build ODBC connection string for SQL server for this refer to connectionstring.com
2. Create object for CDatabase
3. Using CDatabase::Open() function get connection to your database
4. Using CDatabase::ExecteSQL() run your insert query..
5. Finally close the connection CDatabase::Close()..
-suzuu
|
|
|
|
|
Hi all,
I am trying to communicate with HID Devices, but my problem is my ReadFile function always return zero.
I have written the code below
ReadHandle=CreateFile
(detailData->DevicePath,
GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
Result = ReadFile
(ReadHandle,
InputReport,
Capabilities.InputReportByteLength,
&NumberOfBytesRead,
(LPOVERLAPPED) &HIDOverlapped);
Before CreateFile i have used all the necessary api's to get the DevicePath value like SetupDiGetDeviceInterfaceDetail
Now, i am not getting that where is the problem.
Thanks in advance
|
|
|
|
|
From the documentation[^]:
If the function fails, or is completing asynchronously, the return value is zero (FALSE). To get extended error information, call the GetLastError function.
Note The GetLastError code ERROR_IO_PENDING is not a failure; it designates the read operation is pending completion asynchronously. For more information, see Remarks.
You are creating your ReadHandle with FILE_FLAG_OVERLAPPED , if you check GetLastError() after ReadFile , do you maybe get ERROR_IO_PENDING ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Hi,
I have to find the status for a particular file which is currently copying some where or not? If anybody know any DOS commands or have any idea regarding this, please let me know.
Thanks in advance
Suzu
modified on Thursday, July 8, 2010 3:03 AM
|
|
|
|