cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
118
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: null on 20-04-2004 01:11:13 AM
Hi,
In the Audium application, I am building currently, I plan to use multiple Database elements to fetch various information at different point in the call flow. Since some of the query result could be multiple rows, I would like to free up the memory they take up once the resultant rows have been processed.

I intend to free the memory since I perceive the application serving quite a large number of calls at same point of time and the same Audium server hosting more applications also. So I would like to manage the memory usage by my current application as well as other applications.

Is there any way in which I can clear the ResultSetList object's contents once I have processed them? Or any other suggestions on managing memory usage?

Thanks
Samir

Subject: RE: Memory management for ResultSetList objects
Replied by: Michael Bochynski on 20-04-2004 05:33:16 PM
Hi Samir,

Audium is Java based application and hence all the rules applied to Java programs' memory management, apply to Audium. Let me suggest two points where you should look at in terms of memory consumption.

First is the database access. Since ResultSetList object is stored in a current session, it consumes memory. I would suggest getting smaller data at a time, if it possible. Hence, instead of a query:
[code:1:61b8ca3880]SELECT * FROM your_table[/code:1:61b8ca3880]
you could use the following query:
[code:1:61b8ca3880]SELECT col1, col2, ... FROM your_table LIMIT X OFFSET Y [/code:1:61b8ca3880]

where [b:61b8ca3880]X[/b:61b8ca3880] is the number of rows to receive, and [b:61b8ca3880]Y[/b:61b8ca3880] is the first row to obtain. Please refer to your database documentation for more about query management and optimization.

Another issue is memory management in Java programs. According to Java specification, any object that doesn't have any references to it is eligible for a garbage collection and freeing the memory heap. However, in Java you cannot force garbage collection, you can only â¿¿suggestâ¿¿ JVM to run a garbage collection.

Moreover you have to make the ResultSetList object, and any other object for that matter, eligible for a garbage collection. The object is considered as a discarded, and hence eligible for cleaning, when there are other objects referencing to it.

Please refer to the Java documentation for more about Garbage Collection and memory management, i.e. on the

Regards,
Michael

Subject: Alternative to ResultSetList object
Replied by: null on 20-04-2004 11:14:10 PM
Hi Michael,

Thanks for the elaborate response. I do understand the memory management policy of Java and hence understand that since the ResultSetObject is being stored into session, we may not have a way of dereferencing the object itself. But as the List is a sort of 2D array, I was looking for some option to clear the array(list) of its elements.

Well, as another option for this, that I have thought about, can we have database access code in the Config class for other elements, say voice or form element? If yes, this could take care of my concern since them I will get ResultSet from the statement execution which will be de-referenced after execution of the Config class. Also if that is possible, can you guide me to the programming steps?

Thanks
Samir

Subject: RE: Alternative to ResultSetList object
Replied by: Michael Bochynski on 21-04-2004 03:54:52 PM
Hi Samir,

Yes, you can access database in the element's dynamic configuration class as well as in your own custom element. Please refer to our Java sample code and Audium Java Documentation, where you can find valuable information about the use of Java in Audium.

Please refer to the [b:6bd6b487ec]Chapter3_Clock[/b:6bd6b487ec], which illustrates the use of a dynamic configuration for a voice element and Tutorials documentation for explanation of the use of a dynamic configuration.

Regards,
Michael

Subject: RE: Alternative to ResultSetList object
Replied by: Michael Bochynski on 21-04-2004 07:13:37 PM
Hi Samir,

You actually can dereference an object that is stored in the session by using the Audium API to replace that object with null. So, if you have a ResultSetList object in session data named "myResult", you can dereference it by using the method setSessionData("myResult", null) from the com.audium.server.session.ElementAPI object.

Hope this helps,
Michael
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links