From: Bing Li <lb...@gm...> - 2012-09-26 15:50:21
|
Dear all, It is found that a large amount of memory is taken when ranking with PageRank, from JUNG 2.0.1. When starting to rank, the memory consumption goes high and when the ranking is done, it memory usage gets low. According to jconsole, the memory usage jumps with a large range, such as 200M ~1.2G. Is it normal? I am still not sure if it is caused by PageRank. However, I notice one problem that I have to initialize an instance of PageRank and Graph each time when ranking a group. I think it must be better if the PageRank or Graph can be reused. When a new graph is available, PageRank or Graph can be reset or cleared. But no such methods are available, right? Any other ways to solve the potential problem? The code is listed as follows. The method is invoked many times because there are a lot of graphs in my systems and each of them must be ranked periodically. So the memory usage goes up and down in a large range periodically. public Map<T, Double> Rank(HashMap<T, Vertex<T>> vertexMap, Set<Edge<T>> edgeSet) { HashMap<T, Double> finalRankMap = new HashMap<T, Double>(); PageRank<Vertex<T>, Edge<T>> ranker; Graph<Vertex<T>, Edge<T>> graph = new DirectedSparseMultigraph<Vertex<T>, Edge<T>>(); for (Edge<T> edge : edgeSet) { graph.addEdge(edge, edge.GetSourceVertex(), edge.GetDestinationVertex(), EdgeType.DIRECTED); } ranker = new PageRank<Vertex<T>, Edge<T>>(graph, this.weightTransformer, RankingConfig.RANDOM_JUMP_PROPABILITY); ranker.evaluate(); for (Vertex<T> vertex : vertexMap.values()) { try { finalRankMap.put(vertex.GetKey(), ranker.getVertexScore(vertex)); } catch (IllegalArgumentException e) { e.printStackTrace(); } } return finalRankMap; } I appreciates so much for your help! Best regards, Bing |