blob: 1cc8145e90565f06192bd8e28dd56a979dcfcba3 [file] [log] [blame]
Tim Murrayeee2fd82022-11-04 14:46:25 -07001#include <arpa/inet.h>
2#include <cutils/sockets.h>
3#include <fcntl.h>
4#include <hardware/gralloc.h>
5#include <sys/stat.h>
6#include <sys/wait.h>
7#include <unistd.h>
8#include <algorithm>
9#include <chrono>
10#include <fstream>
11#include <iostream>
12#include <numeric>
13#include <string>
14#include <tuple>
15#include <vector>
16
17#include <android-base/stringprintf.h>
18#include <meminfo/procmeminfo.h>
19
20using namespace std;
21
22#define BUFFER_SIZE (1024 * 1024 * 1024)
23
24int main(int, char**) {
25 // waste a bunch of memory
26 void* src = malloc(BUFFER_SIZE);
27 for (size_t i = 0; i < BUFFER_SIZE; i++) {
28 ((char*)src)[i] = (char)i;
29 }
30 void* dst = malloc(BUFFER_SIZE);
31 memcpy(dst, src, BUFFER_SIZE);
32
33 uint64_t pss;
34 // should always return true
35 std::string pid_path = android::base::StringPrintf("/proc/%d/smaps", getpid());
36 while (android::meminfo::SmapsOrRollupPssFromFile(pid_path, &pss))
37 ;
38
39 return 0;
40}