From: Vika F. <ru...@cs...> - 2008-07-23 17:48:31
|
Hi everybody! I have a question about using the pinDown() method in the ElementInfo class. According to the method's documentation, this method allows to keep an object in the heap and not be garbage collected "no matter what". However, I ran into a problem that some of the objects that I pinned down using this method were still garbage collected after the heap was restored using CollapsingRestorer. As far as I can tell, the problem is the following. If an object was created on the heap as an ordinary object (not an internal one) and then later it was pinned down using pinDown() method, this fact can go unnoticed by CollapsingRestorer, which keeps the cache of seen objects and updates it only if an object has been changed. One of the methods that marks an object as changed is analyzeHeap() in DynamicArea. This method marks an object as changed if the object's attributes lastAttrs are not equal to the current value of attributes. However, lastAttrs are set at the beginning of analyzeHeap() to the current value of objects attributes. Thus, for the objects which were pinned down recently, the comparison of lastAttrs to current attributes will always result in equality and these objects will not be marked as changed. In this case, CollapsingRestorer will not update its cache if the value of the pinned down object didn't change (only its attributes) and, when the object is restored later, it will not be pinned down in heap anymore. As a temporary fix, I put a call to markChanged() in analyzeHeap() for all objects whose ATTR_PINDOWN is set and it looks like it solved the problem for me. My question is, is it a bug in JPF or did I use the pinDown() method in unintended way? If it's a bug, what would be a good fix for it? If the method shouldn't be used like that, what would be a good way to force JPF to temporarily keep some objects in memory even when there are no references to these objects left? Thank you in advance! -- Vika |