All Projects → CoderMJLee → Mems

CoderMJLee / Mems

Licence: mit
Utils for viewing memory in Swift.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Mems

Ed4
Computational Cognitive Neuroscience, Fourth Edition
Stars: ✭ 133 (-28.88%)
Mutual labels:  memory
Sysstat
Performance monitoring tools for Linux
Stars: ✭ 2,055 (+998.93%)
Mutual labels:  memory
Redis Rdb Cli
Redis rdb CLI : A CLI tool that can parse, filter, split, merge rdb and analyze memory usage offline. It can also sync 2 redis data and allow user define there own sink service to migrate redis data to somewhere.
Stars: ✭ 176 (-5.88%)
Mutual labels:  memory
Easydeviceinfo
📱 [Android Library] Get device information in a super easy way.
Stars: ✭ 1,698 (+808.02%)
Mutual labels:  memory
Go Cache
This project encapsulates multiple db servers, redis、ledis、memcache、file、memory、nosql、postgresql
Stars: ✭ 143 (-23.53%)
Mutual labels:  memory
Jupiter
A Windows virtual memory editing library with support for pattern scanning.
Stars: ✭ 156 (-16.58%)
Mutual labels:  memory
Slim
Surprisingly space efficient trie in Golang(11 bits/key; 100 ns/get).
Stars: ✭ 1,705 (+811.76%)
Mutual labels:  memory
Loli profiler
Memory instrumentation tool for android app&game developers.
Stars: ✭ 179 (-4.28%)
Mutual labels:  memory
Memflow
physical memory introspection framework
Stars: ✭ 149 (-20.32%)
Mutual labels:  memory
Threejs Sandbox
Set of experiments and extensions to THREE.js.
Stars: ✭ 163 (-12.83%)
Mutual labels:  memory
Mmat
An automatically testing and analysis hprof library for android app (自动分析Android内存泄漏)
Stars: ✭ 137 (-26.74%)
Mutual labels:  memory
Touch Bar Istats
Show CPU/GPU/MEM temperature on Touch Bar with BetterTouchTool!
Stars: ✭ 141 (-24.6%)
Mutual labels:  memory
Mtuner
MTuner is a C/C++ memory profiler and memory leak finder for Windows, PlayStation 4 and 3, Android and other platforms
Stars: ✭ 2,007 (+973.26%)
Mutual labels:  memory
Perf Tools
⏱→ 🚀A set of tools for improving performance your application (balancer, performance, PerfKeeper, LazyPromise).
Stars: ✭ 135 (-27.81%)
Mutual labels:  memory
Unityheapexplorer
A Memory Profiler, Debugger and Analyzer for Unity 2019.3 and newer.
Stars: ✭ 179 (-4.28%)
Mutual labels:  memory
Rxlifecycle
Rx binding of stock Android Activities & Fragment Lifecycle, avoiding memory leak
Stars: ✭ 131 (-29.95%)
Mutual labels:  memory
Dejavu
Quickly detect already witnessed data.
Stars: ✭ 151 (-19.25%)
Mutual labels:  memory
Wgcloud
linux运维监控工具,支持系统信息,内存,cpu,温度,磁盘空间及IO,硬盘smart,系统负载,网络流量等监控,API接口,大屏展示,拓扑图,进程监控,端口监控,docker监控,文件防篡改,日志监控,数据可视化,web ssh,堡垒机,指令下发批量执行,linux面板,探针,故障告警
Stars: ✭ 2,669 (+1327.27%)
Mutual labels:  memory
Mysql Magic
dump mysql client password from memory
Stars: ✭ 183 (-2.14%)
Mutual labels:  memory
Memguard
Secure software enclave for storage of sensitive information in memory.
Stars: ✭ 2,036 (+988.77%)
Mutual labels:  memory

Mems

Utils for viewing memory in Swift.

用来窥探Swift内存的小工具

用法

func show<T>(val: inout T) {
    print("-------------- \(type(of: val)) --------------")
    print("变量的地址:", Mems.ptr(ofVal: &val))
    print("变量的内存:", Mems.memStr(ofVal: &val))
    print("变量的大小:", Mems.size(ofVal: &val))
    print("")
}

func show<T>(ref: T) {
    print("-------------- \(type(of: ref)) --------------")
    print("对象的地址:", Mems.ptr(ofRef: ref))
    print("对象的内存:", Mems.memStr(ofRef: ref))
    print("对象的大小:", Mems.size(ofRef: ref))
    print("")
}

整型

var int8: Int8 = 10
show(val: &int8)
// -------------- Int8 --------------
// 变量的地址: 0x00007ffeefbff598
// 变量的内存: 0x0a
// 变量的大小: 1

var int16: Int16 = 10
show(val: &int16)
// -------------- Int16 --------------
// 变量的地址: 0x00007ffeefbff590
// 变量的内存: 0x000a
// 变量的大小: 2

var int32: Int32 = 10
show(val: &int32)
// -------------- Int32 --------------
// 变量的地址: 0x00007ffeefbff588
// 变量的内存: 0x0000000a
// 变量的大小: 4

var int64: Int64 = 10
show(val: &int64)
// -------------- Int64 --------------
// 变量的地址: 0x00007ffeefbff580
// 变量的内存: 0x000000000000000a
// 变量的大小: 8

枚举

enum TestEnum {
    case test1(Int, Int, Int)
    case test2(Int, Int)
    case test3(Int)
    case test4(Bool)
    case test5
}

var e = TestEnum.test1(1, 2, 3)
show(val: &e)
// -------------- TestEnum --------------
// 变量的地址: 0x00007ffeefbff580
// 变量的内存: 0x0000000000000001 0x0000000000000002 0x0000000000000003 0x0000000000000000
// 变量的大小: 32

e = .test2(4, 5)
show(val: &e)
// -------------- TestEnum --------------
// 变量的地址: 0x00007ffeefbff580
// 变量的内存: 0x0000000000000004 0x0000000000000005 0x0000000000000000 0x0000000000000001
// 变量的大小: 32

e = .test3(6)
show(val: &e)
// -------------- TestEnum --------------
// 变量的地址: 0x00007ffeefbff580
// 变量的内存: 0x0000000000000006 0x0000000000000000 0x0000000000000000 0x0000000000000002
// 变量的大小: 32

e = .test4(true)
show(val: &e)
// -------------- TestEnum --------------
// 变量的地址: 0x00007ffeefbff580
// 变量的内存: 0x0000000000000001 0x0000000000000000 0x0000000000000000 0x0000000000000003
// 变量的大小: 32

e = .test5
show(val: &e)
// -------------- TestEnum --------------
// 变量的地址: 0x00007ffeefbff580
// 变量的内存: 0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000004
// 变量的大小: 32

结构体

struct Date {
    var year = 10
    var test = true
    var month = 20
    var day = 30
}

var s = Date()
show(val: &s)
// -------------- Date --------------
// 变量的地址: 0x00007ffeefbff580
// 变量的内存: 0x000000000000000a 0x0000000000000001 0x0000000000000014 0x000000000000001e
// 变量的大小: 32

class Point  {
    var x = 11
    var test = true
    var y = 22
}

var p = Point()
show(val: &p)
// -------------- Point --------------
// 变量的地址: 0x00007ffeefbff590
// 变量的内存: 0x0000000101023680
// 变量的大小: 8

show(ref: p)
// -------------- Point --------------
// 对象的地址: 0x0000000101023680
// 对象的内存: 0x00000001000072d8 0x0000000200000002 0x000000000000000b 0x0000000000000001 0x0000000000000016 0x3030303030303030
// 对象的大小: 48

数组

var arr = [1, 2, 3, 4]
show(val: &arr)
// -------------- Array<Int> --------------
// 变量的地址: 0x00007ffeefbff598
// 变量的内存: 0x0000000101023800
// 变量的大小: 8

show(ref: arr)
// -------------- Array<Int> --------------
// 对象的地址: 0x0000000101023800
// 对象的内存: 0x00007fff9c30f848 0x0000000200000002 0x0000000000000004 0x0000000000000008 0x0000000000000001 0x0000000000000002 0x0000000000000003 0x0000000000000004
// 对象的大小: 64

字符串

var str1 = "123456789"
// taggerPtr(tagger pointer)
print(str1.mems.type())
show(val: &str1)
// -------------- String --------------
// 变量的地址: 0x00007ffeefbff580
// 变量的内存: 0x3837363534333231 0xe900000000000039
// 变量的大小: 16

var str2 = "1234567812345678"
// text(字符串存储在TEXT段)
print(str2.mems.type())
show(val: &str2)
// -------------- String --------------
// 变量的地址: 0x00007ffeefbff570
// 变量的内存: 0xd000000000000010 0x8000000100007610
// 变量的大小: 16

var str3 = "1234567812345678"
str3.append("9")
// heap(字符串存储在堆空间)
print(str3.mems.type())
show(val: &str3)
// -------------- String --------------
// 变量的地址: 0x00007ffeefbff560
// 变量的内存: 0xf000000000000011 0x00000001007b6ad0
// 变量的大小: 16

show(ref: str3)
// -------------- String --------------
// 对象的地址: 0x00000001007b6ad0
// 对象的内存: 0x00007fff963e9660 0x0000000200000002 0x0000000000000018 0xf000000000000011 0x3837363534333231 0x3837363534333231 0x0000000000200039 0x0000000000000000
// 对象的大小: 64

设置字节显示格式

var int64: Int64 = 10

print("1个字节为1组 :", Mems.memStr(ofVal: &int64, alignment: .one))
// 1个字节为1组 : 0x0a 0x00 0x00 0x00 0x00 0x00 0x00 0x00

print("2个字节为1组 :", Mems.memStr(ofVal: &int64, alignment: .two))
// 2个字节为1组 : 0x000a 0x0000 0x0000 0x0000

print("4个字节为1组 :", Mems.memStr(ofVal: &int64, alignment: .four))
// 4个字节为1组 : 0x0000000a 0x00000000

print("8个字节为1组 :", Mems.memStr(ofVal: &int64, alignment: .eight))
// 8个字节为1组 : 0x000000000000000a
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].