From: SourceForge.net <no...@so...> - 2010-05-27 17:11:37
|
The following forum message was posted by sheybiu at http://sourceforge.net/projects/jung/forums/forum/252062/topic/3723337: Thanks for the quick reply. My class has a SparseMultigraph as global member (m_g). I want to reuse it. My loop is: build graph (fill m_g with nodes and edges), find paths in it, build a new graph (forget the former one), find paths in the new graph and so on. So m_g is a global member of the class and hence will not be collected by the garbage collector just by means of exiting a function. Therefore I need to reset (clear) it. How would you suggest clearing the graph between iterations? I think that the following line should do the work (and expect the garbage collector to automatically be called to free the memory the former graph\'s nodes and edges took): m_g = new SparseMultigraph<TermNode, LexicalEdge>(); As I\'m experiencing an increase in running time and getting memory exception I\'m thinking I might be doing something wrong (i.e. I shouldn\'t have made m_g a global member) or that a memory leak may be the reason. Any how, it is good to hear that it is probably not a JUNG memory problem and if you have any thoughts about the way I use the graph (as far as can be understood from these 2 posts) or suggestions I\'ll be glad to hear them. Thanks, shey |