-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiary10.txt
172 lines (153 loc) · 6.98 KB
/
Diary10.txt
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
【2022-03-30】UE4 Profile内存
1.Stat方法
先输入命令stat startfile 引擎会开始收集每帧的stat数据
然后输入命令stat stopfile 引擎会录制出对应csv文件到目录Saved/Profiling/UnrealStats/里
使用Session Frontend工具加载对应.ue4stats 勾上对应MemoryProfile项能够显示每帧记录的相关内存信息
2.LLM方法
简单来说就是启动时候加上 -LLM -LLMCSV参数
对于Android 启动参数添加方法是往包体储存路径上放置UE4CommandLine.txt
adb.exe push UE4CommandLine.txt /mnt/sdcard/UE4Game/Project/UE4CommandLine.txt
adb.exe push UE4CommandLine.txt /storage/emulated/0/Android/data/com.netease.bfc1game.mainland/files/UE4Game/Project/UE4CommandLine.txt
运行时可以直接输入命令stat LLM
运行后可以在Profiling/LLM找到录制的CSV通过PerfreportTool转化为图表
PerfreportTool.exe -csv LLM_Pid30872_2022.03.08-10.13.03.csv -o h:\LLMOutput -reporttype LLM -topng. -graphxml LLMReportGraphs.xml -reportxml LLMReportTypes.xml -nostripevents
PerfreportTool.exe -csv LLMPlatform_Pid30872_2022.03.08-10.13.03.csv -o h:\LLMOutput -reporttype LLM -topng. -graphxml LLMReportGraphs.xml -reportxml LLMReportTypes.xml -nostripevents
图表里显示的Total的值是利用系统接口获取到物理内存值(其实会减去LLM自己的内存占用) 在PC上是Working Set(包含Private与Shared的) Android上是是RSS
其他除了Untracked的部分都是LLMTracker在每次分配释放时候统计好的,Untracked则是用Total减去其他所有计算出来的值
还有个-LLMTAGSETS加上后(需要加上宏LLM_ALLOW_ASSETS_TAGS)可以查看各个资源的内存使用情况(但是没有办法配合CSVTool转化为图标形式,很鸡肋)
具体可以看https://zhuanlan.zhihu.com/p/78005333 https://www.cnblogs.com/kekec/p/14593345.html
这个统计能够看到每个分类的内存使用情况,很实用
3.memreport -full方法
刚刚提到有需要看各个资源分配的情况 这个时候最好就是用memreport -full方法 结果在Profiling/MemReports里找到
里面会排序好所有资产的内存占用 很实用
【2022-03-30】Android Profile内存
adb shell方法
先提一些基本概念
VSS - Virtual Set Size 虚拟耗用内存(包含共享库占用的内存)
RSS - Resident Set Size 实际使用物理内存(包含共享库占用的内存)
PSS - Proportional Set Size 实际使用的物理内存(比例分配共享库占用的内存)
USS - Unique Set Size 进程独自占用的物理内存(不包含共享库占用的内存)
VSS >= RSS >= PSS >= USS
查看对应进程线程数
adb shell ps -T -p <pid>
查看内存信息
adb shell dumpsys meminfo
显示当前进程进程的状态
adb shell cat /proc/PID/status
显示当前进程各虚拟地址段的属性
adb shell cat /proc/PID/maps
以及查看详细信息
adb shell cat /proc/PID/smaps
adb shell run-as com.*.* cat /proc/PID/smaps
显示进程内存的详细情况
pmap 进程ID
pmap 命令查看虚存大小和分布 ROOT机器才能查看
adb shell pmap PID -x
adb shell run-as com.*.* pmap PID -x
一些使用技巧
adb shell run-as com.*.* pmap PID -x > *.csv
可以把虚存的使用情况输出到csv里
打开后直接重新按空格分列即可
pmap统计出来的PSS可能会比实际的小对比于dumpsys meminfo PID的结果 所以要特别留意对应机型是否存在这个差异
VSS没差
参考:
https://blog.csdn.net/shulianghan/article/details/120854980
https://blog.csdn.net/beckdon/article/details/48491909
https://www.cnblogs.com/arnoldlu/p/10272466.html
https://www.cnblogs.com/arnoldlu/p/8568330.html#maps
【2022-03-30】Android ASAN排查内存问题
Android可以开启ASAN排查内存问题 需要在编译时加上ASAN对应编译选项 APK包体内也需要拷贝对应的so以及wrap.sh文件
之后根据报错地址用addr2line找到对应函数
aarch64-linux-android-addr2line -C -f -e libUE4.so 0x00714a04c480
对于内存断点 AndroidStudio不支持直接通过UI给ARM设置watchpoint
但是可以通过LLDB设置watchpoint实现
w s e -s 8 -- 0x00000043331f0a90
watchpoint set expression -s 8 -- 0x00000049578f3658
参考:
// https://zhuanlan.zhihu.com/p/382994002
// https://zhuanlan.zhihu.com/p/474406153
// https://blog.51cto.com/u_15315240/3226762
// https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html
// https://github.com/google/sanitizers/wiki/AddressSanitizer
【2022-05-27】排查.lib信息
1.dumpbin /symbols *.lib > *.txt
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools\Developer Command Prompt for VS 2022
2.直接用7Zip打开.lib文件
参考:
https://stackoverflow.com/questions/305287/how-to-see-the-contents-of-windows-library-lib
【2022-06-23】排查.a信息
c:\Andriod\SDK\ndk-bundle\toolchains\aarch64-linux-android-4.9\prebuilt\windows-x86_64\aarch64-linux-android\bin\
nm命令
nm -u libacsdk_helper.a
参考:
https://linux.die.net/man/1/nm
【2022-08-03】Android Game Development Extension
https://developer.android.com/games/agde
一个能够在VS上方便调试Android的工具
【2022-10-09】自定义VS Solution Configurations长度
Tools->Customize->Commands->Toolbar->Standard->Solution Configurations
【2023-02-07】自定义UE的VS版本
定位到BuildConfiguration.xml
添加
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
<VCProjectFileGenerator>
<Version>VisualStudio2022</Version>
</VCProjectFileGenerator>
<WindowsPlatform>
<Compiler>VisualStudio2022</Compiler>
</WindowsPlatform>
</Configuration>
【2023-02-22】一些宏使用技巧
在一个inl里使用宏XXX(A, B) 宏这个时候没有被定义
在其他文件里引用这个inl 不同cpp引用这个inl之前各自定义自己的宏XXX
这样一个宏可以多用
例:
.inl:
REGISTER_NAME(1,ByteProperty)
REGISTER_NAME(2,IntProperty)
REGISTER_NAME(3,BoolProperty)
cpp1:
const TCHAR* LexToString(EName Ename)
{
switch (Ename)
{
#define REGISTER_NAME(num,namestr) case num: return TEXT(#namestr);
#include "UObject/UnrealNames.inl"
#undef REGISTER_NAME
default:
return TEXT("*INVALID*");
}
}
h2:
// Define a message as an enumeration.
#define REGISTER_NAME(num,name) NAME_##name = num,
enum EName
{
// Include all the hard-coded names
#include "UnrealNames.inl"
```
// Special constant for the last hard-coded name index
NAME_MaxHardcodedNameIndex,
```
};
#undef REGISTER_NAME
参考:
UE4 UnrealNames.h
【2023-09-10】SimpPerf使用
定位到simpleperf目录
如:AndroidSDK/ndk/21.1.6352462/simpleperf/
执行以下脚本
python app_profiler.py -p com.*.* -lib g:\Client_dev20230629\Intermediate\Android\arm64\jni\arm64-v8a
python report_html.py -i perf.data
或者用AndroidStudio的Profile功能
参考:
https://android.googlesource.com/platform/prebuilts/simpleperf/+/refs/heads/ndk-r13-release/README.md
https://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/README.md
【2023-09-10】meminfo使用
dumpsys meminfo com.example.app
pm list packages | grep "Example App"
ps | grep com.example.app
adb shell dumpsys meminfo
参考:
ChatGPT