私はタイムスタンプ(long)とオブジェクト(safeboxForLongString)を持つマップを含むオブジェクトでいっぱいになるmysqlデータベースを持っています。MySQLとJava - メモリの問題
セーフボックスの文字列は5〜15MBです。
私の問題は、サーバーからStringデータを要求してから約30分後、私のRAMメモリはすでに11-12 GBになっています。私は既にSystem.gcを呼び出して、以前に塗りつぶされたTreeMapをクリアしようとしました。しかし、成功はありません。
私のすべてのRAMを使用する必要はありませんバックアップされたデータベースの目的はありませんか?
私はその問題で常に失敗するため、サーバーデータの収集プロセスを完了できません。私を助けてください。
ここでは、関連するコード
//fill the Database
Main.getAllAvailableEntries().forEach(entryName -> {
final long[] id = {0};
treeMapWrapperRepo.findAll().forEach(entry -> {
if (entry.getCurrency().equals(entryName)) {
id[0] = entry.getMultiHashMapWrapper_id();
}
});
if (id[0] == 0) {
System.out.println("Forming: " + entryName);
final TreeMapWrapper treeMapWrapper = new TreeMapWrapper(entryName);
TreeMap<Long, SafeBoxForLongString> timeStampToSafeBoxMap = new TreeMap<>();
int start = startDateInThePast;
while (start - length >= 0) {
long startDate = instant.minus(start, ChronoUnit.DAYS).getEpochSecond();
long endDate = instant.minus(start - length, ChronoUnit.DAYS).getEpochSecond();
String getReponseWith45DaysLength = dataController.getDataForDB(entryName, startDate, endDate, String.valueOf(resolution));
while (getReponseWith45DaysLength.isEmpty()) {
getReponseWith45DaysLength = dataController.getDataForDB(entryName, startDate, endDate, String.valueOf(resolution));
}
SafeBoxForLongString safeBoxForLongString = new SafeBoxForLongString(getReponseWith45DaysLength);
safeBoxForLongString.setMultiHashMapWrapper(treeMapWrapper);
timeStampToSafeBoxMap.put(startDate, safeBoxForLongString);
treeMapWrapper.setLongSafeTimeAndReponseMap(timeStampToSafeBoxMap);
start--;
}
treeMapWrapperRepo.save(treeMapWrapper);
treeMapWrapper.getLongSafeTimeAndReponseMap().clear();
System.gc();
}
});
編集:1台のスタッカーが言ったように、treeMapWrapperRepo.findAll()。問題だった。
gcを呼び出すときにオブジェクトを参照していないことは間違いありませんか?プロファイラでこれを見てみましたか? –