Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
PKG="com.chrome.canary"
function write_proc_line {
LINE="$1"
TYPE=$(echo $LINE | cut -d, -f2)
PROC=$(echo $LINE | cut -d, -f3)
PID=$(echo $LINE | cut -d, -f4)
OOM_SCORE=$(adb shell cat /proc/$PID/oom_score)
OOM_ADJ=$(adb shell cat /proc/$PID/oom_adj)
$ g++ -o test test.cc --std=c++11 && ./test
<blink_gc>
<allocated_objects>
<net>
<url_request_context>
<app_request, extensions, isolated_media>
<0x?>
<http_cache>
<http_network_session>
<sdch_manager>
@primiano
primiano / test.c
Created March 15, 2017 11:04
proof that mlock doesn't prevent dirty writeback
$cat test.cc
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct Foo {
int a;
int b;
int c;
int d;
int e;
int f;
int g;
int h;
};
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
struct MallocFunctions {
void* malloc_fn;
void* zone;
};
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/mman.h>
#include <signal.h>
typedef void(*Callback)(uintptr_t /*start*/, unsigned long/*size*/, const char* /*prot flags*/, const char* /*fname*/, unsigned long /*pss*/);
void ForEachMapEntry(Callback callback) {
@primiano
primiano / memory-infra-dump-devtools.py
Last active March 10, 2025 04:56
Creates a memory-infra dump using the Chrome Remote Debugging protocol
#!/usr/bin/env python
import argparse
import json
import os
import sys
import tempfile
import time
try:
import websocket
Ubuntu 14.04 on X86_64:
-----------------------
PID 34611 about to die jump 0x0
PID 34611 died with sig 11 Segmentation fault
PID 34612 about to die jump 0x12341230
PID 34612 died with sig 11 Segmentation fault
PID 34613 about to die with __builtin_trap
PID 34613 died with sig 4 Illegal instruction
Android 32 bit binary on armv7:
#!/usr/bin/env python
import json
import gzip
import collections
import os
import re
import sys
def sizeof_fmt(num):
+++ /tmp/patch 2016-05-31 08:34:11.941915136 +0100
--- /tmp/tot 2016-05-31 08:34:06.365874108 +0100
-GLOBAL DEFAULT 13 CyclesPerSecond()
-GLOBAL DEFAULT 13 DefaultSysAllocator::Alloc(unsigned long, unsigned long*, unsigned long)
-GLOBAL DEFAULT 13 DevMemSysAllocator::Alloc(unsigned long, unsigned long*, unsigned long)
-GLOBAL DEFAULT 13 GetHeapProfile
-GLOBAL DEFAULT 13 GetStackFrames(void**, int*, int, int)
-GLOBAL DEFAULT 13 GetStackFramesWithContext(void**, int*, int, int, void const*)
-GLOBAL DEFAULT 13 GetStackTrace(void**, int, int)
-GLOBAL DEFAULT 13 GetStackTraceWithContext(void**, int, int, void const*)