blob: e67d13c2ce4c77cf6a5856fdec51238421cb87cd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*
* Copyright (c) 2014 Eike Stepper (Berlin, Germany) 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Esteban Dugueperoux - initial API and implementation
*/
package org.eclipse.emf.cdo.tests.bugzilla;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.internal.cdo.view.CDOURIHandler;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.URIHandler;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
/**
* Bug 430251 - Memory leak on ResourceSet.
*
* @author Esteban Dugueperoux
*/
public class Bugzilla_430251_Test extends AbstractCDOTest
{
/**
* When the CDOTransaction is closed the ResourceSet should not reference it yet again,
* because the CDOTransaction has a reference to the CDOSession which references the CDORevisionCache which can take many memory.
*/
public void testMemoryLeakOnResourceSet() throws Exception
{
ResourceSet resourceSet = new ResourceSetImpl();
EList<URIHandler> uriHandlers = resourceSet.getURIConverter().getURIHandlers();
assertNull(getCDOURIHandler(uriHandlers));
CDOSession cdoSession = openSession();
CDOTransaction cdoTransaction = cdoSession.openTransaction(resourceSet);
assertNotNull(getCDOURIHandler(uriHandlers));
cdoTransaction.close();
assertNull(getCDOURIHandler(uriHandlers));
}
private Object getCDOURIHandler(EList<URIHandler> uriHandlers)
{
CDOURIHandler cdoURIHandler = null;
for (URIHandler uriHandler : uriHandlers)
{
if (uriHandler instanceof CDOURIHandler)
{
cdoURIHandler = (CDOURIHandler)uriHandler;
break;
}
}
return cdoURIHandler;
}
}
|