Another recycle question

Hi,

I have a Java agent which assigns values to a document using .replaceItemValue(fieldName, fieldValue).

From what I have read (hardly any of it official unfortunately), this will implicitly create a back-end instance to an Item object, the memory for which I am concerned about being orphaned.

Consequently I assign the return value (Item) from the .replaceItemValue so that I can recycle it:

item = doc.replaceItemValue(fieldName, fieldValue);

item.recycle();

So, onto my question… if I set a number of values on the document in one go (initial document setup), do I need to recycle the Item object after every .replaceItemValue?

item = doc.replaceItemValue(fieldName1, fieldValue1);

item.recycle();

item = doc.replaceItemValue(fieldName2, fieldValue2);

item.recycle();

Or is this all a load of rubbish and I don’t have to bother at all?

Thanks in advance!

Jon

p.s. anyone know if there is a agent manager memory leak problem in 6.5.2 for Windows? I’m aware of one on iSeries 6.5.2, but having OutOfMemory issues, hence the drive for recycling… [:frowning:

Subject: Another recycle question…

Have you seen this reference from the Agent FAQ? (There is a section on recycle in the Agent FAQ, this is just one of the references which I believe gives an answer to your question, there is more info there if you have not read I recommend seraching on ‘recycle’ in the Agent FAQ and it will take you to that section)

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/3028acdd0eb5e0c785256ed200791765?OpenDocument

Subject: RE: Another recycle question…

Hi Julie,

Thanks for your response; yes, I had read the FAQ and in particular this document - what isn’t clear (to me at least! [:-)) is how the memory management occurs between the Java to C interface. Take the original example:

doc.replaceItemValue(“ItemA”, “ValueA”)

It’s my understanding that although I only wish to set the field value, a by-product of this Document method call is that an Item object is instantiated on the ‘C’ side. The problem is that I have no way to recycle that memory unless I assign the Item to an object on the ‘Java’ side in order to explicitly recycle it. So the code changes to:

item = doc.replaceItemValue(“ItemA”, “ValueA”)

This is all good, however we come onto my question which is this; in the example below, if I assign the returned Item object to the same java object variable, do I need to recycle the item object before reassigning to again?

So, should I have this

item = doc.replaceItemValue(“ItemA”, “ValueA”)

item = doc.replaceItemValue(“ItemB”, “ValueB”)

item = doc.replaceItemValue(“ItemC”, “ValueC”)

item = doc.replaceItemValue(“ItemD”, “ValueD”)

item.recycle();

…or this?

item = doc.replaceItemValue(“ItemA”, “ValueA”)

item.recycle();

item = doc.replaceItemValue(“ItemB”, “ValueB”)

item.recycle();

item = doc.replaceItemValue(“ItemC”, “ValueC”)

item.recycle();

item = doc.replaceItemValue(“ItemD”, “ValueD”)

item.recycle();

Of course, I could place the name/value pairs into an array and iterate through them in a loop, recycling on each iteration; surely this points to the second example being the correct approach?

In the first example I am concerned about losing the memory on the ‘C’ side for Items A, B & C, recycling only D.

Is this right?

Thanks

Jon

Subject: RE: Another recycle question…

Hi - the second approach is tidiest from a backend point of view. The first will create a lot of activity for the garbage collector to find at some point, possibly much later. c