我去 - 我的序列化XML的异步任务。 在某些特定情况下,我走出去的同时系列化内存不足的错误。 我知道有一个所谓的标志largeHeap
,我可以在我的应用程序中使用。 但是,有没有办法找出具体避免在那个地方。
按我发现System.gc()
是不是可能解决它一个最佳的解决方案。 任何人可以帮助我通过它。 下面的代码片段。
private HashMap<String, Game> games = new HashMap<String, Game>();
public void load(LocalDatabaseHelper localDbHelper) throws Exception
{
synchronized(gameLockObject) {
GameDetailDAO dao = new GameDetailDAO(localDbHelper);
//this will fetch me the all the entities from databse
ArrayList<GameDetailEntity> dbGameDetails = dao.getEntities(null, null);
for (GameDetailEntity gameDetail : dbGameDetails) {
String gameLevel = gameDetail.getDetailLevel();
String gameXml = gameDetail.getGameData();
Game game = null;
if(gameLevel.equalsIgnoreCase("Novice")) {
game = Job.deserialiseJob(gameXml, NoviceLevel.class);
}
else if (gameLevel.equalsIgnoreCase("Expert")) {
game = Job.deserialiseJob(gameXml, ExpertLevel.class);
}
//set the job version
game.setGameversion(gameDetail.getGameVersion());
game.setMagicNumber(gameDetail.getMagicNumber());
game.setInactiveUser(gameDetail.getInactiveUser());
game.setStartTime(gameDetail.getStartTime());
game.setFinishTime(gameDetail.getFinishTime());
game.setGameCompletionTime(gameDetail.getGameCompletionTime());
if (!StringUtils.isNullOrEmpty(gameDetail.getGameStatus())) {
game.setGameStatus(GameStatus.valueOf(gameDetail.getGameStatus()));
}
//add the job to the store
games.put(gameDetail.getGameRef().toLowerCase(Locale.getDefault()), game);
}
}
}