-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shentianzhou
committed
Apr 19, 2021
1 parent
27d357e
commit f1a28f4
Showing
5 changed files
with
78 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,67 +12,68 @@ sensitive information in the file。More importantly, the file is small but the | |
complete, which is very suitable for offline analysis of oom and other exceptions | ||
|
||
## Apps using Tailor | ||
|
||
| <img src="docs/xigua.png" alt="xigua" width="100"/> | <img src="docs/douyin.png" alt="douyin" width="100"/> | <img src="docs/huoshan.png" alt="huoshan" width="100"/> | <img src="docs/kaiyan.png" alt="kaiyan" width="100"/> | ||
|:-----------:|:-------:|:-------:|:-------:| | ||
| Xigua Video | Douyin | Huoshan | Kaiyan | | ||
<img src="docs/xigua.png" width="100"/><img src="docs/douyin.png" width="100"/><img src="docs/huoshan.png" width="100"/><img src="docs/kaiyan.png" width="100"/> | ||
|
||
## Get started | ||
Step 1: Add the JitPack repository to your build file | ||
```gradle | ||
allprojects { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
|
||
Step1: Add to your build.gradle | ||
Step 2: Add the dependency | ||
```gradle | ||
implementation 'com.bytedance.tailor:library:1.0.8' | ||
dependencies { | ||
implementation 'com.github.bytedance:tailor:1.0.9' | ||
} | ||
``` | ||
|
||
Step2: For simple usage | ||
|
||
```java | ||
// Using Tailor to get a mini hprof file in exception callback | ||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
@Override | ||
public void uncaughtException(Thread t, Throwable e) { | ||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mini.hprof"; | ||
try { | ||
Tailor.dumpHprofData(path, true); | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
Step 3: Add code for simple usage | ||
```Java | ||
if (e instanceof java.lang.OutOfMemoryError) { | ||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mini.hprof"; | ||
try { | ||
Tailor.dumpHprofData(path, true); | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
}) | ||
} | ||
``` | ||
|
||
```Java | ||
// Crop and compress the existing hprof files directly | ||
Tailor.cropHprofData(source, target, true); | ||
``` | ||
|
||
Step3: File upload | ||
Step 4: Upload data | ||
```shell | ||
App needs to implement upload logic by itself | ||
## !!! App needs to implement upload logic by itself | ||
``` | ||
|
||
Step4: Data recovery(Python version 3.5 and above) | ||
Step 5: Process data (Python version >= 3.5) | ||
```shell | ||
## Data recovery | ||
python3 library/src/main/python/decode.py -i mini.hprof -o target.hprof | ||
``` | ||
|
||
## Extra | ||
|
||
In order to facilitate everyone to understand the file format of the hprof and the details of cropping | ||
and compression, we provide three script implementations (Python version 3.5 and above) | ||
|
||
```shell | ||
// Hprof verify | ||
## Hprof verify | ||
python3 library/src/main/python/verify.py -i source.hprof | ||
``` | ||
|
||
// Crop and compress | ||
```shell | ||
## Crop and compress | ||
python3 library/src/main/python/encode.py -i source.hprof -o mini.hprof | ||
|
||
// Data recovery | ||
python3 library/src/main/python/decode.py -i mini.hprof -o target.hprof | ||
``` | ||
## Support | ||
|
||
## Extra | ||
1. [Android Camera内存问题剖析](https://mp.weixin.qq.com/s/-oaN-bOqHDjN30UP1FMpgA) | ||
2. [西瓜视频稳定性治理体系建设一:Tailor 原理及实践](https://mp.weixin.qq.com/s/DWOQ9MSTkKSCBFQjPswPIQ) | ||
|
||
## Support | ||
1. Communicate on [GitHub issues](https://github.com/bytedance/tailor/issues) | ||
2. Mail: <a href="mailto:[email protected]">[email protected]</a> | ||
3. WeChat: 429013449 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,65 +7,70 @@ Tailor是西瓜Android团队开发的一款通用内存快照裁剪压缩工具 | |
有任何敏感信息,更重要的是文件非常小的同时数据也相对完整,非常适合离线分析OOM及其他类型异常的调查定位。 | ||
|
||
## Apps using Tailor | ||
|
||
| <img src="docs/xigua.png" alt="xigua" width="100"/> | <img src="docs/douyin.png" alt="douyin" width="100"/> | <img src="docs/huoshan.png" alt="huoshan" width="100"/> | <img src="docs/kaiyan.png" alt="kaiyan" width="100"/> | ||
|:---------:|:-------:|:-------:|:-------:| | ||
| 西瓜视频 | 抖音 | 火山 | 开言英语 | | ||
<img src="docs/xigua.png" width="100"/><img src="docs/douyin.png" width="100"/><img src="docs/huoshan.png" width="100"/><img src="docs/kaiyan.png" width="100"/> | ||
|
||
## Get started | ||
Step 1: Add the JitPack repository to your build file | ||
```gradle | ||
allprojects { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
|
||
Step1 添加依赖: | ||
Step 2: Add the dependency | ||
```gradle | ||
implementation 'com.bytedance.tailor:library:1.0.8' | ||
dependencies { | ||
implementation 'com.github.bytedance:tailor:1.0.9' | ||
} | ||
``` | ||
|
||
Step2 代码接入: | ||
Step 3: Add code for simple usage | ||
```Java | ||
// 在异常回调里通过Tailor获取快照,不同的app异常回调接口不同,可以根据app的实际情况调整,Ex: | ||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { | ||
@Override | ||
public void uncaughtException(Thread t, Throwable e) { | ||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mini.hprof"; | ||
try { | ||
Tailor.dumpHprofData(path, true); | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
// 在异常回调里通过 Tailor 获取快照 | ||
if (e instanceof java.lang.OutOfMemoryError) { | ||
String path = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "mini.hprof"; | ||
try { | ||
Tailor.dumpHprofData(path, true); | ||
} catch (IOException ex) { | ||
ex.printStackTrace(); | ||
} | ||
}) | ||
} | ||
``` | ||
|
||
```Java | ||
// 也可以直接对已经存在的hprof文件裁剪压缩 | ||
Tailor.cropHprofData(source, target, true); | ||
``` | ||
|
||
Step3 数据上传: | ||
Step 4: Upload data | ||
```shell | ||
应用需自己实现上传逻辑或相应的数据回捞功能 | ||
## !!! 应用需自己实现数据上传或回捞 | ||
``` | ||
|
||
Step4 数据还原: | ||
Step 5: Process data (Python version 3.5以上) | ||
```shell | ||
// 还原快照文件(Python version 3.5以上) | ||
## 还原数据, target.hprof 可通过 Android Studio 分析,通过 MAT 还需要 hprof-conv 转换 | ||
python3 library/src/main/python/decode.py -i mini.hprof -o target.hprof | ||
``` | ||
|
||
## Extra | ||
|
||
为了方便大家理解内存快照的文件格式及裁剪压缩细节,我们提供了三个脚本实现(Python version 3.5以上) | ||
```shell | ||
// 解析验证 | ||
## 解析验证 | ||
python3 library/src/main/python/verify.py -i source.hprof | ||
``` | ||
|
||
// 裁剪压缩 | ||
```shell | ||
## 裁剪压缩 | ||
python3 library/src/main/python/encode.py -i source.hprof -o mini.hprof | ||
|
||
// 数据还原 | ||
python3 library/src/main/python/decode.py -i mini.hprof -o target.hprof | ||
``` | ||
## Support | ||
|
||
## Extra | ||
1. [Android Camera内存问题剖析](https://mp.weixin.qq.com/s/-oaN-bOqHDjN30UP1FMpgA) | ||
2. [西瓜视频稳定性治理体系建设一:Tailor 原理及实践](https://mp.weixin.qq.com/s/DWOQ9MSTkKSCBFQjPswPIQ) | ||
|
||
|
||
## Support | ||
1. 在[GitHub issues](https://github.com/bytedance/tailor/issues)上交流 | ||
2. 邮件: <a href="mailto:[email protected]">[email protected]</a> | ||
3. 微信: 429013449 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters