Thomas, if you want to clear all the model data from memory, try to do the 
following:

- clear the EMF ResourceSet used (usually 
org.eclipse.hyades.models.hierarchy.util.HierarchyResourceSetImpl.getInstance()
) in the profile session
- clear the org.eclipse.hyades.loaders.util.LookupServiceExtensions, using 
the following procedure:
        - call LookupServiceExtensions.getInstance().clear() and if that's 
not enough you can also clear each LookupService individually
        - use a copy of LookupServiceRegistryReader to repopulate 
(currently there isn't a way to do that directly) the 
LookupServiceExtensions.getInstance() registry with all the registered 
LookupServices

This should clear up the memory and will give you the same state as when 
you start the workbench at least from TPTP loader/model infrastructure 
perspective.

There still might be model data cached in other parts of the code which 
won't allow the memory to be cleared, if that happens in your scenario 
please let us know.

Thank you,

Marius Slavescu
IBM Tivoli Autonomic Computing - Toronto Lab
Phone: 905-413-3610




Thomas Eichstädt-Engelen <[EMAIL PROTECTED]> 
04/06/2008 11:13 AM
Please respond to
[EMAIL PROTECTED]


To
tptp-tracing-profiling-tools-dev@eclipse.org
cc
Marius Slavescu/Toronto/[EMAIL PROTECTED]
Subject
howto remove traceModel







Hi,

we developed a plugin which starts a large number of profilingSessions
programmatically (Profile As -> JUnit Test). The problem is, each
traceModel is   has its size (in memory) and eclipse runs OutOfMemory
after a while.

To solve that our first approach is like this:

- start ProfilingSession
- store TRCAgent (given by handleProfileEvent)
- do evaluations on the model
- remove the model from memory
- start new ProfilingSession
- ...

We implemented the deleteMethod like this:

// before creating a new traceModel delete the previous one to save memory
public void deletePreviousTrcModel(final TRCAgent trcAgent) {
                 EzUnitPlugin.trace("delete previous trace model");
                 if (trcAgent != null) {
                                 WorkspaceJob delete = new WorkspaceJob(
                                                                 "delete 
previous trace model ...") {
                                                 @Override
                                                 public IStatus 
runInWorkspace(IProgressMonitor arg0)
  throws CoreException {
                                                                 long 
deleteTime = System.currentTimeMillis();

                                                                 // delete 
the old resource object ...
                                                                 Set 
deletedElements = null;
                                                                 try {
  deletedElements = EMFUtil.delete(trcAgent.getProcess());
                                                                 } catch 
(Exception anyException) {
  // do nothing else ... just report this error!
  EzUnitPlugin.logWarn("error while deleting traceModel",
                                 anyException);
                                                                 }
 EzUnitPlugin.trace("deletion of "
                 + (deletedElements != null ? deletedElements.size()
                                                 : -1)
                 + " element took "
                 + String.valueOf(System.currentTimeMillis()
                                                 - deleteTime) + "ms");
                                                                 return 
Status.OK_STATUS;
                                                 }
                                 };
                                 delete.schedule();
                 }
}


Now the memory usage does not grow so fast, but it still grows. So my
assumptions is that i still leave some (big) object left in the model.
Furthermore some NPE occur after the deleteMethod has been called:

Thread[TCPDataFlusher,8,main] - java.lang.NullPointerException
                 at
org.eclipse.hyades.loaders.trace.TraceUtils$InvocationInfo.initInvocationInfo(TraceUtils.java:837)
                 at
org.eclipse.hyades.loaders.trace.TraceUtils$InvocationInfo.update(TraceUtils.java:938)
                 at
org.eclipse.hyades.loaders.trace.TraceUtils$InvocationPool.allocInvocation(TraceUtils.java:972)
                 at
org.eclipse.hyades.loaders.trace.XMLmethodEntryLoader.processENI(XMLmethodEntryLoader.java:124)
                 at
org.eclipse.hyades.loaders.trace.TraceXMLFragmentLoader.dispatchProcessMode(TraceXMLFragmentLoader.java:450)
                 at
org.eclipse.hyades.loaders.trace.XMLmethodEntryLoader.addYourselfInContext(XMLmethodEntryLoader.java:67)
                 at 
org.eclipse.hyades.loaders.util.XMLLoader.endElement(XMLLoader.java:310)
                 at
org.eclipse.hyades.loaders.util.SAXFragmentHandler$RegularHandler.endElement(SAXFragmentHandler.java:175)
                 at 
org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
                 at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
Source)
                 at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
Source)
                 at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
                 at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
                 at 
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                 at 
org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
                 at org.apache.xerces.parsers.XMLParser.parse(Unknown 
Source)
                 at 
org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
                 at 
org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
                 at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown 
Source)
                 at
org.eclipse.hyades.loaders.util.SAXFragmentHandler.parse(SAXFragmentHandler.java:128)
                 at
org.eclipse.hyades.loaders.util.SAXFragmentHandler$1.run(SAXFragmentHandler.java:65)


At least this my question: Could give some pointers where to find
information regarding the _complete_ programmatic deletion of model
objects? Do i probably use the wrong container to delete?

Any help is greatly appreciated. Many thanks in advance,

Thomas E.-E.




_______________________________________________
tptp-tracing-profiling-tools-dev mailing list
tptp-tracing-profiling-tools-dev@eclipse.org
https://dev.eclipse.org/mailman/listinfo/tptp-tracing-profiling-tools-dev

Reply via email to