2
* Copyright (c) 2011 10gen Inc.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Affero General Public License, version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Affero General Public License for more details.
13
* You should have received a copy of the GNU Affero General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include "util/systeminfo.h"
24
size_t SystemInfo::getPhysicalRam() {
26
The value of this should not be changing while the system is running,
27
so it should be safe to do this once for the lifetime of the
30
This could present a race condition if multiple threads do this at
31
the same time, but all paths through here will produce the same
32
result, so it's not worth locking or worrying about it.
34
static bool unknown = true;
35
static size_t ramSize = 0;
38
long pages = sysconf(_SC_PHYS_PAGES);
39
long page_size = sysconf(_SC_PAGE_SIZE);
40
ramSize = pages * page_size;
2
* Copyright (c) 2011 10gen Inc.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Affero General Public License, version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Affero General Public License for more details.
13
* You should have received a copy of the GNU Affero General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include "util/systeminfo.h"
24
size_t SystemInfo::getPhysicalRam() {
26
The value of this should not be changing while the system is running,
27
so it should be safe to do this once for the lifetime of the
30
This could present a race condition if multiple threads do this at
31
the same time, but all paths through here will produce the same
32
result, so it's not worth locking or worrying about it.
34
static bool unknown = true;
35
static size_t ramSize = 0;
38
long pages = sysconf(_SC_PHYS_PAGES);
39
long page_size = sysconf(_SC_PAGE_SIZE);
40
ramSize = pages * page_size;