having 1.5GB RAM I cannot allocate more than 512MB RAM in 4.10
dkouroun at cc.uoi.gr
dkouroun at cc.uoi.gr
Sat Jan 29 03:43:53 PST 2005
Dear FreeBSD list,
I have an AMD Athlon-XP with 1.5GB RAM.
Unfortunately my FreeBSD 4.10 throws a memory allocation
error when in a simple C++ program I try to allocate
with new 512MB of RAM or more. Until 511MB it goes fine!
Is there any kernel specific feature I should tweak?
What is the problem here? I didn't have such problems
with 5.3 Release although it is generally more unstable!
Here is the simple C++ program I used:
--------------------------------------
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
if (argc != 2)
{
cout << "usage: " << argv[0] << " mem(memory to allocate in bytes)\n";
cout << "examp: " << argv[0] << " 1024\n";
exit(1);
}
long int bytes = strtol(argv[1], NULL, 0);
char* buffer = new char[bytes];
cout << "memory allooated succesfully = " << bytes/1024.0/1024.0 << "MB \n";
delete[] buffer;
cout << "allocated memory is now free\n";
return 0;
}
#g++ memalloc -o run
#./run 536870912
which when I tried to run gave a:
---------------------------------
terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Abort (core dumped)
Here is the output of my top command:
------------------------------------
last pid: 432; load averages: 0.00, 0.00, 0.00 up 0+00:35:23 13:37:10
38 processes: 1 running, 37 sleeping
Mem: 63M Active, 39M Inact, 55M Wired, 24K Cache, 50M Buf, 1343M Free
Swap: 3056M Total, 3056M Free
PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
183 root 2 0 84824K 19864K select 0:05 0.00% 0.00% XFree86
190 root 2 0 8916K 7720K poll 0:02 0.00% 0.00% gconfd-2
360 root 2 0 10620K 9720K select 0:02 0.00% 0.00% emacs
242 root 2 0 12464K 9124K poll 0:02 0.00% 0.00% metacity
248 root 2 0 21148K 15472K poll 0:01 0.00% 0.00% nautilus
246 root 2 0 17032K 13108K poll 0:01 0.00% 0.00% gnome-panel
264 root 2 0 16104K 12124K poll 0:01 0.00% 0.00% wnck-applet
266 root 2 0 14148K 9560K poll 0:01 0.00% 0.00% mixer_applet2
188 root 2 0 16124K 10760K poll 0:01 0.00% 0.00% gnome-session
197 root 2 0 16076K 10288K poll 0:01 0.00% 0.00% gnome-settings
268 root 2 0 14924K 11012K poll 0:00 0.00% 0.00% clock-applet
108 root 2 0 920K 528K select 0:00 0.00% 0.00% moused
270 root 2 0 4492K 3552K select 0:00 0.00% 0.00% xterm
432 root 31 0 1912K 1084K RUN 0:00 0.00% 0.00% top
195 root 2 0 5188K 3588K poll 0:00 0.00% 0.00% bonobo-activat
250 root 2 0 6552K 3928K poll 0:00 0.00% 0.00% gnome-vfs-daem
271 root 18 0 1424K 1172K pause 0:00 0.00% 0.00% csh
240 root 2 0 7688K 4656K poll 0:00 0.00% 0.00% gnome-smproxy
More information about the freebsd-questions
mailing list