Closed captain-miao closed 5 years ago
循环创建 AsyncTask,这样容易引发 OOM,支持批量上传比较好。
CacheManager.java 84行
private void fetchDataFromDBAndPost() { List<LogEntity> list = SLSDatabaseManager.getInstance().queryRecordFromDB(); for (final LogEntity item : list) { String clientEndPoint = this.mClient.GetEndPoint(); if (clientEndPoint.equals(item.getEndPoint())) { try { PostCachedLogRequest request = new PostCachedLogRequest(item.getProject(), item.getStore(), item.getJsonString()); AsyncTask<PostCachedLogResult> result = this.mClient.asyncPostCachedLog(request, new CompletedCallback<PostCachedLogRequest, PostCachedLogResult>() { @Override public void onSuccess(PostCachedLogRequest request, PostCachedLogResult result) { SLSDatabaseManager.getInstance().deleteRecordFromDB(item); } @Override public void onFailure(PostCachedLogRequest request, LogException exception) { SLSLog.logError("send cached log failed"); } }); } catch (LogException e) { e.printStackTrace(); } } } }
这个貌似问题不大
循环创建 AsyncTask,这样容易引发 OOM,支持批量上传比较好。
CacheManager.java 84行