mars Android 接入xlog, 内存增长过快,直到oom

pepwfjgg  于 4个月前  发布在  Android
关注(0)|答案(1)|浏览(44)

本地编译的so, 需要保存一些日志到本地,然后上传到服务,接入成功后,打开程序运行了2小时18分后闪退,native内存从程序开始运行的20.2M, 增长到闪退时的60.4M; 如果不写log, 程序可以连续运行3天都没有闪退过。

写log启动时的内存截图

写log闪退时的内存截图

不写log的内存截图

初始化代码
private void initXlog() {
try {
System.loadLibrary("c++_shared");
System.loadLibrary("marsxlog");

// this is necessary, or may crash for SIGBUS
        final String cachePath = this.getFilesDir() + "/xlog";
        String logFileNamePrefix = "xlog";
        //init xlog
        Xlog.XLogConfig logConfig = new Xlog.XLogConfig();
        logConfig.mode = Xlog.AppednerModeAsync;
        logConfig.logdir = Constant.XLOG_PATH;
        logConfig.nameprefix = logFileNamePrefix;
        logConfig.pubkey = "";
        logConfig.compressmode = Xlog.ZLIB_MODE;
        logConfig.compresslevel = 0;
        logConfig.cachedir = cachePath;
        logConfig.cachedays = 0;
        if (BuildConfig.DEBUG) {
            logConfig.level = Xlog.LEVEL_VERBOSE;
            Xlog.setConsoleLogOpen(true);
        } else {
            logConfig.level = Xlog.LEVEL_INFO;
            Xlog.setConsoleLogOpen(false);
        }
        Xlog.appenderOpen(logConfig);
        Log.setLogImp(new Xlog());
    } catch (Exception e) {
        e.printStackTrace();
    }
}

相关问题