Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 07:59 AM
Digital Puer
 
Posts: n/a
Default Running out of memory at under 2GB

I'm running into a problem where my program is running out
of memory at under 2GB, but lsattr says my realmem is 8GB.

I have compiled with xlC -q64 and different -bmaxdata values,
but to no avail.

Below is a simple program that uses an STL vector and
pushes random unsigned long long integers (8 bytes).
It fails at counter=136216567, meaning that it runs out of
memory at 136216567*8=1089732536 bytes = 1GB (and I
assume the next vector reallocation will push the vector
past 2GB).


Can someone suggest what I can do? I would like to be able
to use up as much of my system's 8GB as possible.


Compile:
xlC -bmaxdata:0x80000000 -O5 -qunroll -q64 memorytest.C


#include <stdio.h>
#include <vector>
#include <string.h>
#include <time.h>
#include <stdlib.h> /* random, srandom */

using namespace std;

vector<unsigned long long> v;

main()
{
unsigned long long value;
int counter;
srandom(time(NULL));

for (counter = 0; counter < 500000000; counter++)
{
value = ((unsigned long long)random() << 32) | (unsigned
long)random();
try
{
v.push_back(value);
}
catch(bad_alloc ex)
{
perror("problem: ");
printf("push_back failed: %s\n", ex.what());
printf("counter = %d\n", counter);
printf("vector capacity: %d\n", v.capacity());
exit(1);
}
if ((counter % 2000000) == 0) printf("%d\n", counter);
}


}





The end result is:
problem: : Not enough space
push_back failed: bad allocation
counter = 136216567
vector capacity: 136216567

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 07:59 AM
Dan Foster
 
Posts: n/a
Default Re: Running out of memory at under 2GB

In article <1133144242.046705.46250@g43g2000cwa.googlegroups. com>, Digital Puer <digital_puer@hotmail.com> wrote:
> I'm running into a problem where my program is running out
> of memory at under 2GB, but lsattr says my realmem is 8GB.


What OS version?

This is a fundamental limitation of anything before v5.

With v5 and onwards, a non-issue, particularly on 64-bit hardware, I
believe.

-Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 07:59 AM
Patrick Begou
 
Posts: n/a
Default Re: Running out of memory at under 2GB

I do'nt think that -bmaxdata is needed with -q64 option set.
Some points to check:

- What dit the "ulimit -a" command returns ?

- Is your kernel 64 bits ?
#ls -l /unix
lrwxrwxrwx 1 root system 21 Mar 20 2003 /unix ->
/usr/lib/boot/unix_64

Patrick

Digital Puer wrote:
> I'm running into a problem where my program is running out
> of memory at under 2GB, but lsattr says my realmem is 8GB.
>
> I have compiled with xlC -q64 and different -bmaxdata values,
> but to no avail.
>
> Below is a simple program that uses an STL vector and
> pushes random unsigned long long integers (8 bytes).
> It fails at counter=136216567, meaning that it runs out of
> memory at 136216567*8=1089732536 bytes = 1GB (and I
> assume the next vector reallocation will push the vector
> past 2GB).
>
>
> Can someone suggest what I can do? I would like to be able
> to use up as much of my system's 8GB as possible.
>
>
> Compile:
> xlC -bmaxdata:0x80000000 -O5 -qunroll -q64 memorytest.C
>
>
> #include <stdio.h>
> #include <vector>
> #include <string.h>
> #include <time.h>
> #include <stdlib.h> /* random, srandom */
>
> using namespace std;
>
> vector<unsigned long long> v;
>
> main()
> {
> unsigned long long value;
> int counter;
> srandom(time(NULL));
>
> for (counter = 0; counter < 500000000; counter++)
> {
> value = ((unsigned long long)random() << 32) | (unsigned
> long)random();
> try
> {
> v.push_back(value);
> }
> catch(bad_alloc ex)
> {
> perror("problem: ");
> printf("push_back failed: %s\n", ex.what());
> printf("counter = %d\n", counter);
> printf("vector capacity: %d\n", v.capacity());
> exit(1);
> }
> if ((counter % 2000000) == 0) printf("%d\n", counter);
> }
>
>
> }
>
>
>
>
>
> The end result is:
> problem: : Not enough space
> push_back failed: bad allocation
> counter = 136216567
> vector capacity: 136216567
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-05-2008, 07:59 AM
Digital Puer
 
Posts: n/a
Default Re: Running out of memory at under 2GB

Here is ulimit -a :

time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 131072
stack(kbytes) 32768
memory(kbytes) 32768
coredump(blocks) 0
nofiles(descriptors) 2000



Here is /unix :

/unix@ -> /usr/lib/boot/unix_6







Patrick Begou wrote:
> I do'nt think that -bmaxdata is needed with -q64 option set.
> Some points to check:
>
> - What dit the "ulimit -a" command returns ?
>
> - Is your kernel 64 bits ?
> #ls -l /unix
> lrwxrwxrwx 1 root system 21 Mar 20 2003 /unix ->
> /usr/lib/boot/unix_64
>
> Patrick
>
> Digital Puer wrote:
> > I'm running into a problem where my program is running out
> > of memory at under 2GB, but lsattr says my realmem is 8GB.
> >
> > I have compiled with xlC -q64 and different -bmaxdata values,
> > but to no avail.
> >
> > Below is a simple program that uses an STL vector and
> > pushes random unsigned long long integers (8 bytes).
> > It fails at counter=136216567, meaning that it runs out of
> > memory at 136216567*8=1089732536 bytes = 1GB (and I
> > assume the next vector reallocation will push the vector
> > past 2GB).
> >
> >
> > Can someone suggest what I can do? I would like to be able
> > to use up as much of my system's 8GB as possible.
> >
> >
> > Compile:
> > xlC -bmaxdata:0x80000000 -O5 -qunroll -q64 memorytest.C
> >
> >
> > #include <stdio.h>
> > #include <vector>
> > #include <string.h>
> > #include <time.h>
> > #include <stdlib.h> /* random, srandom */
> >
> > using namespace std;
> >
> > vector<unsigned long long> v;
> >
> > main()
> > {
> > unsigned long long value;
> > int counter;
> > srandom(time(NULL));
> >
> > for (counter = 0; counter < 500000000; counter++)
> > {
> > value = ((unsigned long long)random() << 32) | (unsigned
> > long)random();
> > try
> > {
> > v.push_back(value);
> > }
> > catch(bad_alloc ex)
> > {
> > perror("problem: ");
> > printf("push_back failed: %s\n", ex.what());
> > printf("counter = %d\n", counter);
> > printf("vector capacity: %d\n", v.capacity());
> > exit(1);
> > }
> > if ((counter % 2000000) == 0) printf("%d\n", counter);
> > }
> >
> >
> > }
> >
> >
> >
> >
> >
> > The end result is:
> > problem: : Not enough space
> > push_back failed: bad allocation
> > counter = 136216567
> > vector capacity: 136216567
> >


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-05-2008, 07:59 AM
Dan Foster
 
Posts: n/a
Default Re: Running out of memory at under 2GB

In article <1133205637.014501.157820@g47g2000cwa.googlegroups .com>, Digital Puer <digital_puer@hotmail.com> wrote:
> Here is ulimit -a :
>
> time(seconds) unlimited
> file(blocks) unlimited
> data(kbytes) 131072
> stack(kbytes) 32768
> memory(kbytes) 32768
> coredump(blocks) 0
> nofiles(descriptors) 2000


1. What is the OS version?

If it is 4.3.3 or older, you are stuck with 2 GB max.

2. What is the type-model number of the hardware? E.g. 9076-270, etc.

If you are running 5.1 or later on 64-bit hardware, then you're almost
there. You might consider adjusting some of the ulimit values, though.

-Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-05-2008, 07:59 AM
Digital Puer
 
Posts: n/a
Default Re: Running out of memory at under 2GB


Dan Foster wrote:
> In article <1133205637.014501.157820@g47g2000cwa.googlegroups .com>, Digital Puer <digital_puer@hotmail.com> wrote:
> > Here is ulimit -a :
> >
> > time(seconds) unlimited
> > file(blocks) unlimited
> > data(kbytes) 131072
> > stack(kbytes) 32768
> > memory(kbytes) 32768
> > coredump(blocks) 0
> > nofiles(descriptors) 2000

>
> 1. What is the OS version?
>
> If it is 4.3.3 or older, you are stuck with 2 GB max.
>
> 2. What is the type-model number of the hardware? E.g. 9076-270, etc.
>
> If you are running 5.1 or later on 64-bit hardware, then you're almost
> there. You might consider adjusting some of the ulimit values, though.



I am not sure about the OS version, but 'uname -a' returns this:

AIX XXX 2 5 0004A20D4C00

the model number is: IBM,7028-6E4

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-05-2008, 08:00 AM
Michael Kraemer
 
Posts: n/a
Default Re: Running out of memory at under 2GB

In article <1133213728.997183.239820@z14g2000cwz.googlegroups .com>, "Digital
Puer" <digital_puer@hotmail.com> writes:
>
> I am not sure about the OS version, but 'uname -a' returns this:
>
> AIX XXX 2 5 0004A20D4C00


that's 5.2
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-05-2008, 08:00 AM
Dan Foster
 
Posts: n/a
Default Re: Running out of memory at under 2GB

In article <1133213728.997183.239820@z14g2000cwz.googlegroups .com>, Digital Puer <digital_puer@hotmail.com> wrote:
>
> I am not sure about the OS version, but 'uname -a' returns this:
>
> AIX XXX 2 5 0004A20D4C00


That's AIX 5.2. (Another way to tell: 'oslevel')

> the model number is: IBM,7028-6E4


Ahh, good. That's 64-bit hardware. Also, your serial number apparently
is 10-4A20D. (Also can see it from 'lsattr -El sys0 -a systemid')

Your ulimit settings seems to be restricting you. Might want to set
'data', 'memory', and possibly 'stack' to unlimited values for the user
you are running the application for.

# vi /etc/security/limits

will do the trick. Not sure if you have to reboot or not.

You can set it in the default entry or override default entry with
specific per-user settings.

You may also have insufficient swap space configured?

What does 'lsps -a' say?

My first test failed almost at 1 GB (but not at that exact point)
because I ran out of paging (swap) space even though I had *plenty* of
physical memory left.

You can tell if this happens because programs gets killed and 'errpt'
mentions VMM messages and software program abnormally terminated, with
'errpt -a|more' mentioning due to system running out of paging space.

I am testing it on one of my AIX 5.2 machines with VisualAge C/C++ 6.0 +
latest patches for both OS and VAC.

-Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-05-2008, 08:00 AM
Dan Foster
 
Posts: n/a
Default Re: Running out of memory at under 2GB

In article <slrndonaea.2rn.usenet@zappy.catbert.org>, Dan Foster <usenet@evilphb.org> wrote:
> You may also have insufficient swap space configured?
>
> What does 'lsps -a' say?
>
> My first test failed almost at 1 GB (but not at that exact point)
> because I ran out of paging (swap) space even though I had *plenty* of
> physical memory left.
>
> You can tell if this happens because programs gets killed and 'errpt'
> mentions VMM messages and software program abnormally terminated, with
> 'errpt -a|more' mentioning due to system running out of paging space.


I tested your program on one of my 64-bit AIX 5.2 machines. The test
aborted early because I did not have enough paging space configured.

But I did verify that with your compile flags and no -bmaxdata option, I
was able to hit 1.6 GB allocated before test failed.

I am sure it would have had passed 2 GB if I had more paging space set
up and if I had used very large program support with right bmaxdata
flags. I already had ulimit set to unlimited.

I can't set up more paging space on that machine because it is a
production server, and I do not have a similar sized test machine.

But basically, you need to look at three more things: ulimit, paging
space, and -bmaxdata option.

1. You probably need at least 8 GB of paging space configured.

# smitty lvm
Paging Space
Add Another Paging Space
<pick which VG to put PS on>
<enter number of LPs for PS>
<go down to 'Start using this paging space NOW?', press tab to set to yes>
<go down to 'Use this paging space each time the system is RESTARTED?',
press tab to set to yes>
<press enter to execute>
<press esc-0 or F10 when done with SMIT>

# lsps -a

2. Read this IBM page on very large program support:

http://publib16.boulder.ibm.com/pser...rg_support.htm

It applies to AIX 5.1 and later.

It suggests using: -bmaxdata:0xD0000000/dsa instead of what you used
before. That turns on *Very* large program support. Large Program
Support is NOT enough because that is limited to 2 GB RAM.

3. Adjust ulimit (see other post on how to do it).

-Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 01-05-2008, 08:00 AM
Patrick Begou
 
Posts: n/a
Default Re: Running out of memory at under 2GB

As says Dan Foster
1) increase your paging space (may be add a second one if you want
easily remove it later)

2) increase your limits for data and memory in /etc/security/limits
(stack not needed in you case I think).

These are the parameters for an AIX 5.2 with 8 Gbytes memory here:
#lsps -a
Page Space Physical Volume Volume Group Size %Used Active
Auto Type
paging00 hdisk0 rootvg 3968MB 5 yes
yes lv
hd6 hdisk0 rootvg 3968MB 5 yes
yes lv
#ulimit -a
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) unlimited
stack(kbytes) 4194304
memory(kbytes) unlimited
coredump(blocks) 2097151
nofiles(descriptors) unlimited

Takes care, data and memory are in 512bytes blocs in /etc/security.
You need to loogout/logon after changing this file (no reboot needed).

Patrick



Digital Puer wrote:
> Here is ulimit -a :
>
> time(seconds) unlimited
> file(blocks) unlimited
> data(kbytes) 131072
> stack(kbytes) 32768
> memory(kbytes) 32768
> coredump(blocks) 0
> nofiles(descriptors) 2000
>
>
>
> Here is /unix :
>
> /unix@ -> /usr/lib/boot/unix_6
>
>
>
>
>
>
>
> Patrick Begou wrote:
>
>>I do'nt think that -bmaxdata is needed with -q64 option set.
>>Some points to check:
>>
>>- What dit the "ulimit -a" command returns ?
>>
>>- Is your kernel 64 bits ?
>>#ls -l /unix
>>lrwxrwxrwx 1 root system 21 Mar 20 2003 /unix ->
>>/usr/lib/boot/unix_64
>>
>>Patrick
>>
>>Digital Puer wrote:
>>
>>>I'm running into a problem where my program is running out
>>>of memory at under 2GB, but lsattr says my realmem is 8GB.
>>>
>>>I have compiled with xlC -q64 and different -bmaxdata values,
>>>but to no avail.
>>>
>>>Below is a simple program that uses an STL vector and
>>>pushes random unsigned long long integers (8 bytes).
>>>It fails at counter=136216567, meaning that it runs out of
>>>memory at 136216567*8=1089732536 bytes = 1GB (and I
>>>assume the next vector reallocation will push the vector
>>>past 2GB).
>>>
>>>
>>>Can someone suggest what I can do? I would like to be able
>>>to use up as much of my system's 8GB as possible.
>>>
>>>
>>>Compile:
>>>xlC -bmaxdata:0x80000000 -O5 -qunroll -q64 memorytest.C
>>>
>>>
>>>#include <stdio.h>
>>>#include <vector>
>>>#include <string.h>
>>>#include <time.h>
>>>#include <stdlib.h> /* random, srandom */
>>>
>>>using namespace std;
>>>
>>>vector<unsigned long long> v;
>>>
>>>main()
>>>{
>>> unsigned long long value;
>>> int counter;
>>> srandom(time(NULL));
>>>
>>> for (counter = 0; counter < 500000000; counter++)
>>> {
>>> value = ((unsigned long long)random() << 32) | (unsigned
>>>long)random();
>>> try
>>> {
>>> v.push_back(value);
>>> }
>>> catch(bad_alloc ex)
>>> {
>>> perror("problem: ");
>>> printf("push_back failed: %s\n", ex.what());
>>> printf("counter = %d\n", counter);
>>> printf("vector capacity: %d\n", v.capacity());
>>> exit(1);
>>> }
>>> if ((counter % 2000000) == 0) printf("%d\n", counter);
>>> }
>>>
>>>
>>>}
>>>
>>>
>>>
>>>
>>>
>>>The end result is:
>>>problem: : Not enough space
>>>push_back failed: bad allocation
>>>counter = 136216567
>>>vector capacity: 136216567
>>>

>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:59 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524