1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 22:55:26 +02:00

[373507] [dstore][multithread] reduce heap memory on disconnect for server

This commit is contained in:
David McKnight 2012-03-07 14:14:17 +00:00
parent dd35bf78c6
commit 7e326c2026
4 changed files with 61 additions and 14 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2011 IBM Corporation and others.
* Copyright (c) 2002, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -20,6 +20,7 @@
* David McKnight (IBM) - [232004] [dstore][multithread] some miner finish() is not terminated sometimes
* David McKnight (IBM) - [328060] [dstore] command queue in Miner should be synchronized
* David McKnight (IBM) - [358301] [DSTORE] Hang during debug source look up
* David McKnight (IBM) - [373507] [dstore][multithread] reduce heap memory on disconnect for server
*******************************************************************************/
package org.eclipse.dstore.core.miners;
@ -129,24 +130,24 @@ implements ISchemaExtender
*/
public void finish()
{
synchronized (_commandQueue){
_commandQueue.clear();
}
DataElement root = _dataStore.getMinerRoot();
_minerData.removeNestedData();
_minerElement.removeNestedData();
_dataStore.update(_minerElement);
if (root.getNestedData() != null)
{
if (root != null && root.getNestedData() != null){
root.getNestedData().remove(_minerElement);
root.setExpanded(false);
root.setUpdated(false);
_dataStore.update(root);
}
root.setExpanded(false);
root.setUpdated(false);
_dataStore.update(root);
super.finish();
}
/**
* Interface to retrieve an NL enabled resource bundle.
* Override this function to get access to a real resource bundle.

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2008 IBM Corporation and others.
* Copyright (c) 2002, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -13,6 +13,7 @@
*
* Contributors:
* David McKnight (IBM) - [226561] [apidoc] Add API markup to RSE Javadocs where extend / implement is allowed
* David McKnight (IBM) - [373507] [dstore][multithread] reduce heap memory on disconnect for server
*******************************************************************************/
package org.eclipse.dstore.core.model;
@ -85,10 +86,15 @@ public final class DataElement implements IDataElement
DataElementRemover.addToCreatedCount();
}
/* Apparently having this method causes the GC to delay
* cleanup for DataElements. For a product this delayed cleanup
* can potentially result in an OOM so, at the expense of the
* memory logging function, we need to take this out.
protected void finalize()
{
DataElementRemover.addToGCedCount();
}
*/
/**
* Initializes a <code>DataElement</code> to be reference to some other <code>DataElement</code>.

View file

@ -41,6 +41,7 @@
* David McKnight (IBM) - [366070] [dstore] fix for bug 351993 won't allow tracing if .dstoreTrace doesn't exist
* David McKnight (IBM) - [367096] [dstore] DataElement.isSpirit() may return true for newly created DStore objects
* David McKnight (IBM) - [370260] [dstore] log the RSE version in server traces
* David McKnight (IBM) - [373507] [dstore][multithread] reduce heap memory on disconnect for server
*******************************************************************************/
package org.eclipse.dstore.core.model;
@ -2643,9 +2644,35 @@ public final class DataStore
flush(_descriptorRoot);
flush(_dummy);
flush(_root);
flush(_externalRoot);
// make sure these aren't null set since
// Miners need them on shutdown
// _logRoot = null;
// _minerRoot = null;
_hostRoot = null;
_tempRoot = null;
_descriptorRoot = null;
_dummy = null;
_root = null;
_externalRoot = null;
_status = null;
_ticket = null;
// clear the maps
_classReqRepository.clear();
_cmdDescriptorMap.clear();
_hashMap.clear();
_lastCreatedElements.clear();
_localClassLoaders.clear();
_objDescriptorMap.clear();
_relDescriptorMap.clear();
_remoteLoader = null;
}
/**
* Delete information from the <code>DataStore</code> contained by an element.
*
@ -4204,6 +4231,14 @@ public final class DataStore
// which causes havoc for iSeries caching when switching between offline / online
//if (isVirtual())
// flush();
if (!isVirtual()){ // only on server
if (getClient() != null){
getClient().getLogger().logInfo(this.getName(), "DataStore.finish() - flush()"); //$NON-NLS-1$
}
flush();
}
if (_deRemover != null){
_deRemover.finish();
}

View file

@ -18,6 +18,7 @@
* David McKnight (IBM) - [294933] [dstore] RSE goes into loop
* David McKnight (IBM) - [331922] [dstore] enable DataElement recycling
* David McKnight (IBM) - [371401] [dstore][multithread] avoid use of static variables - causes memory leak after disconnect
* David McKnight (IBM) - [373507] [dstore][multithread] reduce heap memory on disconnect for server
*******************************************************************************/
package org.eclipse.dstore.internal.core.util;
@ -37,7 +38,7 @@ public class DataElementRemover extends Handler
private static int numRemoved = 0;
private static int numDisconnected = 0;
private static int numCreated = 0;
private static int numGCed = 0;
//private static int numGCed = 0;
// The following determine how DataElements are chosen to be removed once they
// are in the queue for removal.
@ -100,7 +101,7 @@ public class DataElementRemover extends Handler
public static void addToGCedCount()
{
numGCed++;
//numGCed++;
}
@ -152,7 +153,9 @@ public class DataElementRemover extends Handler
_dataStore.memLog("Elements created so far: " + numCreated); //$NON-NLS-1$
_dataStore.memLog("Elements disconnected so far: " + numDisconnected); //$NON-NLS-1$
_dataStore.memLog("Spirit elements cleaned so far: " + numRemoved); //$NON-NLS-1$
_dataStore.memLog("DataElements GCed so far: " + numGCed); //$NON-NLS-1$
// no longer a helpful stat since we no longer use finalize
// _dataStore.memLog("DataElements GCed so far: " + numGCed); //$NON-NLS-1$
return;
}
_dataStore.memLog("Total heap size before disconnection: " + Runtime.getRuntime().totalMemory()); //$NON-NLS-1$
@ -190,7 +193,9 @@ public class DataElementRemover extends Handler
_dataStore.memLog("Elements created so far: " + numCreated); //$NON-NLS-1$
_dataStore.memLog("Elements disconnected so far: " + numDisconnected); //$NON-NLS-1$
_dataStore.memLog("Spirit elements cleaned so far: " + numRemoved); //$NON-NLS-1$
_dataStore.memLog("DataElements GCed so far: " + numGCed); //$NON-NLS-1$
// no longer a helpful stat since we no longer use finalize
// _dataStore.memLog("DataElements GCed so far: " + numGCed); //$NON-NLS-1$
System.gc();
}
}