Clinton,
 
What do you mean?  What would cause that type of condition in the SQL Maps?
 
Daniel

________________________________

From: Clinton Begin [mailto:[EMAIL PROTECTED]
Sent: Thu 3/8/2007 8:50 AM
To: [email protected]
Subject: Re: What is RequestScope used for?


>>  The snapshot I took showed 402 objects of the SqlMapClientImpl a

It's now clear to me that you're building more than one SQL Map 
instance...possibly one per thread.   

It's not your transactional code, it's wherever you're building your DAOManager 
or your SqlMapClient. 

Clinton


On 3/8/07, Daniel Kalcevich <[EMAIL PROTECTED]> wrote: 

        OK, I went ahead and changed the places where DaoManager is used and 
made the logic something like the following:
        
        try {
             DAOManager.startTransaction();
        
             ...something...
        
            DAOManager.commitTransaction ();
        } finally {
           DAOManager.endTransaction();
        }
        
        After making those changes, I am still seeing those RequestScope 
objects in Memory.  The snapshot I took showed 402 objects of the 
SqlMapClientImpl and 205, 824 objects of the Request Scope. 
        
        Is there any place else I should look to help with these RequestScope 
Objects?
        
        Daniel
        
        ________________________________
        
        From: Kalcevich, Daniel [mailto:[EMAIL PROTECTED] ]
        Sent: Tue 3/6/2007 10:11 AM
        To: [email protected]
        Subject: RE: What is RequestScope used for?
        
        
        
        Clinton,
        
        
        
        Thanks for the help.  I will change the DaoManager to handle the 
transactions at the points in the code where I am using them.  That way, should 
I perform any calls that require transactions, they will already be there.  
I'll try it out and let you know if I run into any more problems. 
        
        
        
        Daniel
        
        
        
        ________________________________
        
        >> With regards to the DAO framework side of it, could I just wrap any 
calls to the SQL maps
        >> with a try/finally that always calls the endTransaction() method on 
the SqlMapClient? 
        
        No, don't do that.  The iBATIS DAO framework is very similar to Spring. 
 It handles the transactions inside the DAOs for you.  But the consumer of the 
DAOs shoudl be starting and ending transactions on the DaoManager within a 
try/finally block. 
        
        >> Because all of them are only SELECT statements, I don't really need 
transactions inside the library itself.
        >> Or do I actually need to insert the startTransaction() and 
commitTransaction() methods regardless? 
        
        No, you don't need start/commit/end if you're just doing selects.  You 
can just call the DAO methods.  Just make sure you're not calling start without 
a corresponding end....
        
        Clinton
        
        ________________________________ 
        
        From: Kalcevich, Daniel
        Sent: Tuesday, March 06, 2007 9:46 AM
        To: '[email protected]'
        Subject: RE: What is RequestScope used for?
        
        
        
        Clinton,
        
        
        
        Yes, the applications run inside the same JVM.
        
        
        
        As for the Spring, I have already posted something to the Spring forum 
verifying that the way in which we use them are correct, and they appear to be. 
        
        
        
        With regards to the DAO framework side of it, could I just wrap any 
calls to the SQL maps with a try/finally that always calls the endTransaction() 
method on the SqlMapClient?  Because all of them are only SELECT statements, I 
don't really need transactions inside the library itself.  Or do I actually 
need to insert the startTransaction() and commitTransaction() methods 
regardless? 
        
        
        
        Daniel
        
        
        
        ________________________________
        
        Is this all in the same VM?
        
        Spring is the recommended DAO solution and is probably the way that at 
least 50% of iBATIS users use it.  You don't need to worry about transactions 
at all with Spring, it will take care of it (as far as iBATIS is concerned at 
least).  Have a look at the spring docs to ensure that you're using it the 
right way. 
        
        I agree that you should start by looking at the other part that uses 
your own lib with iBATIS DAO.  With iBATIS DAO you need to ensure you're 
starting and ending transactions in a try/finally block just like with 
SqlMapClient. 
        
        Cheers,
        Clinton
        
        
        
        ________________________________
        
        From: Kalcevich, Daniel
        Sent: Tuesday, March 06, 2007 9:29 AM
        To: '[email protected] '
        Subject: RE: What is RequestScope used for?
        
        
        
        Clinton,
        
        
        
        Thanks for the response.  Now with regards to the Transactions... our 
application uses SQL Maps in two different ways.
        
        
        
        1.      Within Spring inside the Web App - We use transactions within 
Spring, thus SQL maps should not be using the transactions.
        2.      A library we developed that the Web App uses - This uses the 
DAO framework and SQL Maps internally, but only retrieves information from the 
DB, not inserts. 
        
        
        
        For the Transactions, do I have to declare them explicitly in both 
places, or do you think it would be better to address the standalone library 
first?
        
        
        
        Daniel
        
        
        
        ________________________________ 
        
        Yep, you have a leak and it is RequestScope related...but it's likely 
not an ibatis bug...
        
        It's more likely that you're not ending transactions properly.
        
        try {
          sqlMapClient.startTransaction ();
          ///... do work
        } finally {
          sqlMapClient.endTransaction();
        }
        
        Clinton
        
        
        
        ________________________________
        
        From: Kalcevich, Daniel
        Sent: Tuesday, March 06, 2007 8:18 AM
        To: ' [email protected]'
        Subject: RE: What is RequestScope used for?
        
        
        
        OK, upon looking at the Yourkit, I am showing the number of objects in 
memory as the following: 
        
        
        
        -          com.ibatis.sqlmap.engine.impl.SqlMapClientImpl - 212 objects 
with a total retained size in memory of 31.38MB
        
        -          com.ibatis.sqlmap.engine.scope.RequestScope - 108, 544 
objects with a total retained size in memory of 16.49MB.
        
        -          com.ibatis.sqlmap.engine.scope.SessionScope - 27,136 objects 
with a total retained size in memory of 3.03 MB.
        
        
        
        Do those numbers make sense?  I only question it because with every 
snapshot of the memory I have taken along the way, the 
RequestScope/SessionScope objects keep increasing. 
        
        
        
        Daniel
        
        
        
        ________________________________
        
        From: Kalcevich, Daniel
        Sent: Tuesday, March 06, 2007 7:04 AM
        To: '[email protected] '
        Subject: RE: What is RequestScope used for?
        
        
        
        I found about this RequestScope through the profiler YourKit.  Here is 
the trail that references the IBatis objects.
        
        
        
        map of com.ibatis.sqlmap.engine.scope.RequestScope 
        
        --[121] of java.lang.Object[513]
        
        ---elementData of java.util.ArrayList
        
        ----list of java.util.Collections$SynchronizedRandomAccessList
        
        -----pool of com.ibatis.common.util.ThrottledPool
        
        ------requestPool of com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelega 
te
        
        ------delegate of com.ibatis.sqlmap.engine.impl.SqlMapClientImpl
        
        -------client of com.ibatis.dao.engine.transaction.sqlmap.SqlMapDao 
TransactionManager
        
        --------transactionManager of com.ibatis.dao.engine.impl.DaoContext
        
        ---------[0] of java.lang.Object[11]
        
        ----------elementData of java.util.ArrayList
        
        -----------value of java.lang.ThreadLocal$ThreadLocalMap$Entry 
        
        ------------[1442] of java.lang.ThreadLocal$ThreadLocalMap$Entry[2049]
        
        -------------table of java.lang.ThreadLocal$ThreadLocalMap
        
        --------------threadLocals of java.lang.Thread [Stack Local, Thread]
        
        
        
        
        
        The reason I thought it might be contributing to a memory leak was the 
fact that at every snapshot I take, the number of HashMaps continues to 
increase without going down.  Then when I look at what it is referring to, it 
points to the RequestScope. 
        
        
        
        While looking in the trace, I saw that it was referencing the 
DaoContext's transaction Manager.  Could the Transaction Manager be playing a 
part in this?  My application uses Spring with SQL Maps, but a library we wrote 
uses the DAO Framework specifically.  The Spring application does not use it.  
I think that is worth looking into, given what I see in the profiler. 
        
        
        
        Daniel
        
        
        
        
        
        ________________________________
        
        From: Kalcevich, Daniel
        Sent: Monday, March 05, 2007 11:37 AM
        To: '[email protected] '
        Subject: What is RequestScope used for?
        
        
        
        Hello,
        
        
        
        I have a Spring, Struts, SQL Map application that runs on JBoss/Tomcat. 
 And while going through a profiler, I am seeing that there are several 
instances of " com.ibatis.sqlmap.engine.scope.RequestScope".  What is that 
object used for?  The reason I ask is that I am trying to track down a memory 
leak and am wondering if this class is possibly part of the cause?  Any help is 
greatly appreciated.  Thank you. 
        
        
        
        Daniel
        
        
        


<<winmail.dat>>

Reply via email to