Potential Memory Leak in rmi

We have a service that is being monitored via JMX. The JVM heap usage is growing and even major collections are not able to remove the garbage. Inspecting the heap shows garbage consisting of RMI related references (mostly, if not all, related class loaders). The only way to alleviate the issue is to issue explicit gc call through JMX (that removes all accumulated garbage). Our gc related options are:
-XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:SurvivorRatio=8 -XX:MaxTenuringThreshold=1 -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly
And we have not touched either of: DisableExplicitGC or sun.rmi.dgc.server.gcInterval
I believe the problem is supposed to addressed by the code in sun.misc.GC.Daemon:
public void run() { for (;;) { long l; synchronized (lock) {  l = latencyTarget; if (l == NO_TARGET) { /* No latency target, so exit */ GC.daemon = null; return; }  long d = maxObjectInspectionAge(); if (d >= l) { /* Do a full collection. There is a remote possibility * that a full collection will occurr between the time * we sample the inspection age and the time the GC * actually starts, but this is sufficiently unlikely * that it doesn't seem worth the more expensive JVM * interface that would be required. */ System.gc(); d = 0; }  /* Wait for the latency period to expire, * or for notification that the period has changed */ try { lock.wait(l - d); } catch (InterruptedException x) { continue; } } } }
For some reason the above System.gc is not being invoked (that has been verified by looking at gc logs). Anyone has a suggestion as to how to address the issue?

Thanks for pointing to MOS notes, they were quite helpful. Though sometime on our system, ohasd.bin consumes more resources. Is it safe to kill it?
Also, we have observed that there are multiple oraagents belonging to different users such as root,grid and oracle.
grid 14620 1 0 20:32 ? 00:00:14 /u01/app/11.2.0/grid/bin/oraagent.bin
root 14625 1 0 20:32 ? 00:00:02 /u01/app/11.2.0/grid/bin/orarootagent.bin
root 14627 1 0 20:32 ? 00:00:00 /u01/app/11.2.0/grid/bin/cssdagent
grid 14803 1 0 20:32 ? 00:00:06 /u01/app/11.2.0/grid/bin/oraagent.bin
oracle 14807 1 0 20:32 ? 00:01:53 /u01/app/11.2.0/grid/bin/oraagent.bin
root 14811 1 0 20:32 ? 00:00:38 /u01/app/11.2.0/grid/bin/orarootagent.bin
When these are killed, not all are re-spawned automatically - typically oraagent belonging to "oracle" user is left out. Is this an expected behaviour or it will cause some instability in the clusterware?
Thanks

Similar Messages

  • Potential Memory Leak during Marshelling of a Web Service Response

    I believe I have found a memory leak when using the configuration below.
    The memory leak occurs when calling a web service. When the web service function is marshelling the response of the function call, an "500 Internal Server Error ... java.lang.OutOfMemoryError" is returned from OC4J. This error may be seen via the TCP Packet Monitor in JDeveloper.
    Unfortunately no exception dump is outputted to the OC4J log.
    Configuration:
    Windows 2000 with 1 gig ram
    JDeveloper 9.0.5.2 with JAX/RPC extension installed
    OC4J 10.0.3
    Sun JVM version 1.4.2_03-b02
    To demonstrate the error I created a simple web service and client. See below the client and web service function that demonstrates it.
    The web service is made up of a single function called "queryTestOutput".
    It returns an object of class "TestOutputQueryResult" which contains an int and an array.
    The function call accepts a one int input parameter which is used to vary the size of array in the returned object.
    For small int (less than 100). Web service function returns successfully.
    For larger int and depending on the size of memory configuration when OC4J is launched,
    the OutOfMemoryError is returned.
    The package "ws_issue.service" contains the web service.
    I used the Generate JAX-RPC proxy to build the client (found in package "ws_issue.client"). Package "types" was
    also created by Generate JAX-RPC proxy.
    To test the web service call execute the class runClient. Vary the int "atestValue" until error is returned.
    I have tried this with all three encodings: RPC/Encoded, RPC/Literal, Document/Literal. They have the
    same issue.
    The OutOfMemory Error is raised fairly consistently using the java settings -Xms386m -Xmx386m for OC4J when 750 is specified for the input parameter.
    I also noticed that when 600 is specified, the client seems to hang. According to the TCP Packet Monitor,
    the response is returned. But, the client seems unable to unmarshal the message.
    ** file runClient.java
    // -- this client is using Document/Literal
    package ws_issue.client;
    public class runClient
    public runClient()
    * @param args
    * Test out the web service
    * Play with the atestValue variable to until exception
    public static void main(String[] args)
    //runClient runClient = new runClient();
    long startTime;
    int atestValue = 1;
    atestValue = 2;
    //atestValue = 105; // last one to work with default memory settings in oc4j
    //atestValue = 106; // out of memory error as seen in TCP Packet Monitor
    // fails with default memory settings in oc4j
    //atestValue = 600; // hangs client (TCP Packet Monitor shows response)
    // when oc4j memory sessions are -Xms386m -Xmx386m
    atestValue = 750; // out of memory error as seen in TCP Packet Monitor
    // when oc4j memory sessions are -Xms386m -Xmx386m
    try
    startTime = System.currentTimeMillis();
    Ws_issueInterface ws = (Ws_issueInterface) (new Ws_issue_Impl().getWs_issueInterfacePort());
    System.out.println("Time to obtain port: " + (System.currentTimeMillis() - startTime) );
    // call the web service function
    startTime = System.currentTimeMillis();
    types.QueryTestOutputResponse qr = ws.queryTestOutput(new types.QueryTestOutput(atestValue));
    System.out.println("Time to call queryTestOutput: " + (System.currentTimeMillis() - startTime) );
    startTime = System.currentTimeMillis();
    types.TestOutputQueryResult r = qr.getResult();
    System.out.println("Time to call getresult: " + (System.currentTimeMillis() - startTime) );
    System.out.println("records returned: " + r.getRecordsReturned());
    for (int i = 0; i<atestValue; i++)
    types.TestOutput t = r.getTestOutputResults();
    System.out.println(t.getTestGroup() + ", " + t.getUnitNumber());
    catch (Exception e)
    e.printStackTrace();
    ** file wsmain.java
    package ws_issue.service;
    import java.rmi.RemoteException;
    import javax.xml.rpc.ServiceException;
    import javax.xml.rpc.server.ServiceLifecycle;
    public class wsmain implements ServiceLifecycle, ws_issueInterface
    public wsmain()
    public void init (Object p0) throws ServiceException
    public void destroy ()
    System.out.println("inside ws destroy");
    * create an element of the array with some hardcoded values
    private TestOutput createTestOutput(int cnt)
    TestOutput t = new TestOutput();
    t.setComments("here are some comments");
    t.setConfigRevisionNo("1");
    t.setItemNumber("123123123");
    t.setItemRevision("arev" + cnt);
    t.setTestGroup(cnt);
    t.setTestedItemNumber("123123123");
    t.setTestedItemRevision("arev" + cnt);
    t.setTestResult("testResult");
    t.setSoftwareVersion("version");
    t.setTestConditions("conditions");
    t.setStageName("world's a stage");
    t.setTestMode("Test");
    t.setTestName("test name");
    t.setUnitNumber("UnitNumber"+cnt);
    return t;
    * Web service function that is called
    * Create recCnt number of "records" to be returned
    public TestOutputQueryResult queryTestOutput (int recCnt) throws java.rmi.RemoteException
    System.out.println("Inside web service function queryTestOutput");
    TestOutputQueryResult r = new TestOutputQueryResult();
    TestOutput TOArray[] = new TestOutput[recCnt];
    for (int i = 0; i< recCnt; i++)
    TOArray[i] = createTestOutput(i);
    r.setRecordsReturned(recCnt);
    r.setTestOutputResults(TOArray);
    System.out.println("End of web service function call");
    return r;
    * @param args
    public static void main(String[] args)
    wsmain wsmain = new wsmain();
    int aval = 5;
    try
    TestOutputQueryResult r = wsmain.queryTestOutput(aval);
    for (int i = 0; i<aval; i++)
    TestOutput t = r.getTestOutputResults()[i];
    System.out.println(t.getTestGroup() + ", " + t.getUnitNumber());
    catch (Exception e)
    e.printStackTrace();
    ** file ws_issueInterface.java
    package ws_issue.service;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface ws_issueInterface extends java.rmi.Remote
    public TestOutputQueryResult queryTestOutput (int recCnt) throws java.rmi.RemoteException;
    ** file TestOutputQueryResult.java
    package ws_issue.service;
    public class TestOutputQueryResult
    private long recordsReturned;
    private TestOutput[] testOutputResults;
    public TestOutputQueryResult()
    public long getRecordsReturned()
    return recordsReturned;
    public void setRecordsReturned(long recordsReturned)
    this.recordsReturned = recordsReturned;
    public TestOutput[] getTestOutputResults()
    return testOutputResults;
    public void setTestOutputResults(TestOutput[] testOutputResults)
    this.testOutputResults = testOutputResults;
    ** file TestOutput.java
    package ws_issue.service;
    public class TestOutput
    private String itemNumber;
    private String itemRevision;
    private String configRevisionNo;
    private String testName;
    private String testConditions;
    private String stageName;
    private String testedItemNumber;
    private String testedItemRevision;
    private String unitNumber;
    private String testStation;
    private String testResult;
    private String softwareVersion;
    private String operatorID;
    private String testDate; // to be datetime
    private String comments;
    private int testGroup;
    private String testMode;
    public TestOutput()
    public String getComments()
    return comments;
    public void setComments(String comments)
    this.comments = comments;
    public String getConfigRevisionNo()
    return configRevisionNo;
    public void setConfigRevisionNo(String configRevisionNo)
    this.configRevisionNo = configRevisionNo;
    public String getItemNumber()
    return itemNumber;
    public void setItemNumber(String itemNumber)
    this.itemNumber = itemNumber;
    public String getItemRevision()
    return itemRevision;
    public void setItemRevision(String itemRevision)
    this.itemRevision = itemRevision;
    public String getOperatorID()
    return operatorID;
    public void setOperatorID(String operatorID)
    this.operatorID = operatorID;
    public String getSoftwareVersion()
    return softwareVersion;
    public void setSoftwareVersion(String softwareVersion)
    this.softwareVersion = softwareVersion;
    public String getStageName()
    return stageName;
    public void setStageName(String stageName)
    this.stageName = stageName;
    public String getTestConditions()
    return testConditions;
    public void setTestConditions(String testConditions)
    this.testConditions = testConditions;
    public String getTestDate()
    return testDate;
    public void setTestDate(String testDate)
    this.testDate = testDate;
    public String getTestName()
    return testName;
    public void setTestName(String testName)
    this.testName = testName;
    public String getTestResult()
    return testResult;
    public void setTestResult(String testResult)
    this.testResult = testResult;
    public String getTestStation()
    return testStation;
    public void setTestStation(String testStation)
    this.testStation = testStation;
    public String getTestedItemNumber()
    return testedItemNumber;
    public void setTestedItemNumber(String testedItemNumber)
    this.testedItemNumber = testedItemNumber;
    public String getTestedItemRevision()
    return testedItemRevision;
    public void setTestedItemRevision(String testedItemRevision)
    this.testedItemRevision = testedItemRevision;
    public String getUnitNumber()
    return unitNumber;
    public void setUnitNumber(String unitNumber)
    this.unitNumber = unitNumber;
    public int getTestGroup()
    return testGroup;
    public void setTestGroup(int testGroup)
    this.testGroup = testGroup;
    public String getTestMode()
    return testMode;
    public void setTestMode(String testMode)
    this.testMode = testMode;

    I use web services a lot and I sympathize with your issue. I
    struggle with similar issues and I found this great utility that
    will help you confirm if your webservice is returning the data
    correctly to Flex. I know you said it works in other applications
    but who knows if flex is calling it correctly etc. This utility is
    been the most amazing tool in helping me resolve web service
    issues.
    http://www.charlesproxy.com/
    Once you can confirm the data being returned is good you can
    try several things in flex. Try changing your result format to
    object or e4x etc. See how that plays out. Not sure where your
    tapping in to look at your debugger, you might want to catch it
    right at the result handler before converting to any collections. .
    If nothing here helps maybe post some code to look at. .
    .

  • Potential memory leak in 11.2.0.1.0 cluster stack components

    Hi All,
    We are running 11.2.0.1.0 RAC on OEL 5.5 and OEL 5.5. On all of our boxes, we have observed a gradual increase and filling of swap space. Swap usage slowly but steadily increase to a point where either the Node boots automatically or we have to manually restart it.
    To get more insight into the issues, we recently upgraded one of the nodes to Oracle unbreakable kernel and installed smem to profile the memory consumption pattern. smem will give the process set size (RSS), the unique set size (USS) and the proportional set size (PSS) which is the unique set size plus a portion of the shared memory that is being used by this process.
    It appears that there is a gradual increase in memory/swap consumption of some clusterware components. Also the weird part is that the process is filling up the swap space and not utilizing the unallocated RAM.
    Memory footprint at the Node start...
    PID User Command Swap USS PSS RSS
    4001 root /u01/app/11.2.0/grid/bin/ohasd.bin 16236 18128 18829 30284
    5200 oracle /u01/app/11.2.0/grid/bin/oraagent.bin 13536 74512 75587 87156
    4255 grid /u01/app/11.2.0/grid/bin/oraagent.bin 13484 2644 3628 15056
    4688 root /u01/app/11.2.0/grid/bin/crsd.bin 8240 71584 72628 85692
    Memory footprint after 24 hrs...
    PID User Command Swap USS PSS RSS
    5200 oracle /u01/app/11.2.0/grid/bin/oraagent.bin 94952 121168 122161 133488
    4688 root /u01/app/11.2.0/grid/bin/crsd.bin 66220 76684 77723 90776
    4001 root /u01/app/11.2.0/grid/bin/ohasd.bin 21448 24708 25410 36892
    4255 grid /u01/app/11.2.0/grid/bin/oraagent.bin 13840 2372 3202 14316
    #free -m
    total used free shared buffers cached
    Mem: 3964 3856 108 0 5 1846
    -/+ buffers/cache: 2004 1959
    Swap: 4094 617 3477
    Has anyone experience similar situation? I did google search as well as Metalink, but did not find anything useful.
    Any thoughts/suggestions are welcome.
    Thanks,
    -Sanjeev
    Edited by: user12219014 on Jan 9, 2011 5:58 AM

    Thanks for pointing to MOS notes, they were quite helpful. Though sometime on our system, ohasd.bin consumes more resources. Is it safe to kill it?
    Also, we have observed that there are multiple oraagents belonging to different users such as root,grid and oracle.
    grid 14620 1 0 20:32 ? 00:00:14 /u01/app/11.2.0/grid/bin/oraagent.bin
    root 14625 1 0 20:32 ? 00:00:02 /u01/app/11.2.0/grid/bin/orarootagent.bin
    root 14627 1 0 20:32 ? 00:00:00 /u01/app/11.2.0/grid/bin/cssdagent
    grid 14803 1 0 20:32 ? 00:00:06 /u01/app/11.2.0/grid/bin/oraagent.bin
    oracle 14807 1 0 20:32 ? 00:01:53 /u01/app/11.2.0/grid/bin/oraagent.bin
    root 14811 1 0 20:32 ? 00:00:38 /u01/app/11.2.0/grid/bin/orarootagent.bin
    When these are killed, not all are re-spawned automatically - typically oraagent belonging to "oracle" user is left out. Is this an expected behaviour or it will cause some instability in the clusterware?
    Thanks

  • Memory leak in RMI registry ? (JRE 1.3.1_11)

    Hello. I have a CLI that creates a server which calls some JNI to get
    objects for a flat file database and return them. Each time I run the CLI I create a new server and bind it the RMI registry. I created a script that excecutes
    the CLI in a forever loop. While this is running I notice the RMI registry program
    slowly grows over time until it uses all of the system resources. I keep track of the
    servers I create in a Vector and remove them once they are complete. I don't
    explicitly remove them from the RMI registry because I assume they would get
    garbage collected once all references to them where gone. Has anyone seen
    this behavior ? Any ideas what could be happening ? Thanks.
    BTW - I am running on Solaris.

    The only way out of the RMI Registry is the unbind() method.
    If you never unbind anything from the RMI REgistry and keep adding bindings it will grow forever.
    You've got your implementation back to front. If you unbind from the Registry then allow DGC to take its course your server will eventually get an Unreferenced callback, which is the signal to remove it from local storage. Alternatively you could just unbind() and remove from local storage immediately. To be frank I am amazed that you didn't try this before posting here.

  • Memory leak analysis

    I've been writing a multi-threaded, non-blocking I/O game server and I'm kinda taking a break from hammering out code at the moment to analyze how efficient the server is. With 100-300 clients each transmitting data and receiving a proper response once every second or so, the server has almost 0% CPU load (on an AMD 4000+ 64bit CPU) so I am very happy with this.
    However, I find that with -verbose:gc on, I can watch the memory every so slowly leak away.. for instance, I will lose around 3 kb / minute with an initial stack of 128mb, 256mb max with a few clients, and this can get as high as 100kb / minute with 200 clients hammering the server. I have looked quite hard at the code and I cannot see anywhere where I am continuously allocating memory and retaining references to it, so everything should be getting GC'd, but some additional kilobytes remain after each GC.
    What I am wondering is, how can I profile the memory usage to, for instance, have an up-to-date count of how many objects of type X (including Strings and ArrayLists and stuff) that are currently in existance at any given time? This would at least give me a better idea of where this potential memory leak is?
    Thanks in advance,
    James

    You may find the JVM is still warming up. It attempts to optimise as it goes and can still be consuming more memory as it re-optimises.

  • URGENT: Memory leak in UIX 2.1.7?????

    We are using UIX 2.1.7 and when searching for potential memory leaks we found a situation where UIX does not release some of our dataObjects after a page has been rendered. Analyzing the problem we found out that there are CompositeRenderingContext objects which seem to be reused but they always maintain a reference to the dataObjects that have been used when rendering the last page.
    The references are: CompositeRenderingContext holds CompositeRenderingContext holds Comp...... holds TableRenderingContext holds CustomDataObject
    In our case this is a very bad behaviour because some of our dataObjects are quite large and maintain references to lots of other objects, which can never be released (even after all users logged out) unless the RenderingContext releases our dataObjects.
    So my question:
    Are these observations correct?
    Is there a way to make the renderingContext release the dataObjects after rendering the page - or to explicitly say remove all unused renderingContext objects?
    How many such CompositeRenderingContext trees can the UIXFramework at most hold?
    Please help - this is very urgent as we have a customer that thinks the memory consumption of our application grows indefinitely and they cannot go into production with such a problem.
    Thanks,
    Guido

    Hi Guido,
    This was fixed in UIX 2.1.16 and UIX 2.2.0. This is not an unbounded memory leak; it will eventually peak. Patching to UIX 2.1.16 or later will resolve the problem. You'll have to contact your Oracle support team to get this release. I'm not sure how that works.
    JDeveloper 10g Preview has UIX 2.2.
    Thanks,
    Jeanne

  • Memory leaks in NI-DAQ 6.9.1

    Can anyone tell me if the API for NI-DAQ 6.9.1 has been purified to eliminate all memory leaks? I'm using DIG_Block_In() etc. with PCI-653X DIO cards. My Win2K MSC++ V6 Purify (tm) reports many potential leaks similar to the following:
    [I] MPK: Potential memory leak of 11550 bytes from 350 blocks allocated in RegistrySession::~RegistrySession(void)
    Distribution of potentially leaked blocks
    11550 bytes from 350 blocks of 33 bytes (first block: 0x04a34ae8)
    Allocation location
    malloc [msvcrt.DLL]
    RegistrySession::~RegistrySession(void) [nipsm.dll]
    moot::moot(basic_string,allocator> const&) [nipsm.dll]
    moot::moot(basic
    _string,allocator> const&) [nipsm.dll]
    moot::load(PSMQueue&) [nipsm.dll]
    BinaryFileProxy::Load(PSMQueue&) [nipsm.dll]
    BinaryFileProxy::Begin(void) [nipsm.dll]
    KeyProxy:pen(moot const&,DWORD) [nipsm.dll]
    CfqCloseConnectionToServer [nicfq32.dll]
    CfqQueryDigitalAvailability [nicfq32.dll]
    moot::moot(basic_string,allocator> const&) [nipsm.dll]

    John,
    Thanks for your reply. I'll include another Purify "Potential Leak" report and try to annotate it more.
    This is the biggest reported leak at 11550 bytes from the destructor of an object called RegistrySession found in nipsm.dll.
    The lines below "RegistrySession::~RegistrySession(void) [nipsm.dll]" form a call stack reading down. ie object moot called RegistrySession, and BinaryFileProxy::Load() called that, etc. The RegistrySession destructor is really the only culprit for allocating memory then losing it. The whole chain of events starts, however, at a call to CfqQueryDigitalAvailability in the nicfq32.dll.
    Now, my application certainly didn't call this and I have no idea what it's trying to do, but I suspect that it's called sometime
    during the loading and initialization of nidaq32.dll which I link against.
    If you indeed Purify your libraries prior to release then you should be able to duplicate my results.
    I can send you my code if you like.
    Thanks for you help,
    Dan Stine
    MPK: Potential memory leak of 11550 bytes from 350 blocks allocated in RegistrySession::~RegistrySession(void)
    Distribution of potentially leaked blocks
    Allocation location
    malloc [msvcrt.dll]
    RegistrySession::~RegistrySession(void) [nipsm.dll]
    moot::moot(basic_string,allocator> const&) [nipsm.dll]
    moot::moot(basic_string,allocator> const&) [nipsm.dll]
    moot::load(PSMQueue&) [nipsm.dll]
    BinaryFileProxy::Load(PSMQueue&) [nipsm.dll]
    BinaryFileProxy::Begin(void) [nipsm.dll]
    KeyProxy:pen(moot const&,DWORD) [nipsm.dll]
    CfqCloseConnection
    ToServer [nicfq32.dll]
    CfqQueryDigitalAvailability [nicfq32.dll]

  • RMI memory leak

    My program use RMI, and I remark memory leak, then I tried RMI sample from jbuilder6, I modified this sample, to send 1Mb file via RMI.
    I write how much RAM are used
    before 168 mb
    rmiregistry 172Mb used 8 Mb
    RMIserver 189Mb 18 Mb
    RMIclient up to 227Mb 38Mb
    end when RMIclient exit 212Mb where is 23 Mb??? 212-189 ????
    This is my changes, and all program are after that:
    public String getDate() {
    System.out.println("SimpleRMIImpl.getDate()");
    String s=null;
    try {
    InputStream fileIn = new FileInputStream("Readme.txt2");
    byte buff[] = new byte[fileIn.available()];
    int i = fileIn.read(buff);
    s = new String(buff);
    } catch(FileNotFoundException e) {
    e.printStackTrace();
    } catch(IOException e) {
    e.printStackTrace();
    return new String(s);
    All program:
    package com.borland.samples.rmi;
    import java.rmi.*;
    import java.rmi.registry.*;
    import java.rmi.server.*;
    import java.util.Date;
    public class SimpleRMIClient
    public static void main(String[] argv) {
    String serverName = "";
    System.setSecurityManager(new RMISecurityManager());
    if (argv.length != 1) {
    try {
    serverName = java.net.InetAddress.getLocalHost().getHostName();
    catch(Exception e) {
    e.printStackTrace();
    else {
    serverName = argv[0];
    if (serverName == "") {
    System.out.println("usage: java SimpleRMIClient <IP address of host running RMI server>");
    System.exit(0);
    try {
    //bind server object to object in client
    SimpleRMIInterface myServerObject = (SimpleRMIInterface) Naming.lookup("//"+serverName+"/SimpleRMIImpl instance");
    //invoke method on server object
    String d = myServerObject.getDate();
    System.out.println("Date on server is " + d);
    catch(Exception e) {
    System.out.println("Exception occured: " + e);
    System.exit(0);
    System.out.println("RMI connection successful");
    package com.borland.samples.rmi;
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.FileInputStream;
    public class SimpleRMIImpl extends UnicastRemoteObject implements SimpleRMIInterface
    public SimpleRMIImpl(String name) throws RemoteException {
    super();
    try {
    Naming.rebind(name, this);
    catch (Exception e) {
    if (e instanceof RemoteException)
    throw (RemoteException)e;
    else
    throw new RemoteException(e.getMessage());
    public String getDate() {
    System.out.println("SimpleRMIImpl.getDate()");
    String s=null;
    try {
    InputStream fileIn = new FileInputStream("Readme.txt2");
    byte buff[] = new byte[fileIn.available()];
    int i = fileIn.read(buff);
    s = new String(buff);
    } catch(FileNotFoundException e) {
    e.printStackTrace();
    } catch(IOException e) {
    e.printStackTrace();
    return new String(s);
    package com.borland.samples.rmi;
    public interface SimpleRMIInterface extends java.rmi.Remote
    public String getDate() throws java.rmi.RemoteException;
    package com.borland.samples.rmi;
    import java.rmi.*;
    import java.rmi.server.UnicastRemoteObject;
    public class SimpleRMIServer
    public static void main(String[] argv) {
    System.setSecurityManager(new RMISecurityManager());
    try {
    SimpleRMIImpl implementation = new SimpleRMIImpl("SimpleRMIImpl instance");
    System.out.println("SimpleRMIImpl ready");
    catch (Exception e) {
    System.out.println("Exception occurred: " + e);
    Can you explain why this program use so much memory?
    Valdas

    Memory Usage and its distribution are done by the JVM....u cannot posibly account for each Mega bit of memory while it is used. Also, the File Copying Operation Involves JVM interacting with the OS which in turn interacts with the peripeherals such as ur harddisk, which are comparetively slower then the Processor speed. So the bottom line is ur same program will work at different RAM levels in diff machines with diff hardwares......If u system is indeed working too much then u can check out and sut down many services that u might have otherwise started...posiiblity of a Virus should not be ruled out either.....and the code itself is no problem at all although u might increase a bit by using some FIleReader, BufferredReader/Writer and other faster Streams.
    Hope it helps,
    Cheers,
    Manja

  • ClassDefiner.defineClass() leaking memory in a RMI method invocation.

    Hi,
    My application uses RMI for communicating between two java processes.
    I'm observing some kind of memory leak in one of the classes in RMI
    library. When observed through OptimizeIT, I see a large number of
    Object[] being created by the ClassDefiner.defineClass() &
    ClassDefiner$1().run().
    These Object[] arrays keep accumulating, never get garbage collected.
    Attached is the screen shot of OptimizeIT, which shows object allocation
    hierarchy.
    Any help in this regard would be appreciated.
    The JDK version being used is, 1.4.2_05.
    thanks in advance.
    Vijayendra

    Update -
    The reason for this was found to be "-Xnoclassgc" After removing this option from the startup script, I didn't notice any increase in object[]/int[] count.
    Hoping this would fix the issue.

  • RMI method invocation leading to Memory Leak

    My application uses RMI for communicating between two java processes.
    I'm observing some kind of memory leak in one of the classes in RMI
    library. When observed through OptimizeIT, I see a large number of
    Object[] being created by the ClassDefiner.defineClass() &
    ClassDefiner$1().run().
    These Object[] arrays keep accumulating, never get garbage collected.
    Attached is the screen shot of OptimizeIT, which shows object allocation
    hierarchy.
    Any help in this regard would be appreciated.
    The JDK version being used is, 1.4.2_05.
    thanks in advance.
    Vijayendra

    The reason for this was found to be "-Xnoclassgc" After removing this option from the startup script, I didn't notice any increase in object[]/int[] count.
    Hoping this would fix the issue.

  • Memory leak in  NFS server

    Hi all,
    I have a problem with 2 SunFire 240 (4Gb of Ram) with solaris 10 in a Veritas Cluster.
    These nodes are 2 NFS server and they have 10 nfs client.
    We have a memory leak on these servers. The memory utilization increase day by day.
    The memory seems to be allocated by the kernel and not from some process.
    So I would like to know if this is a common issue (NFS?) or this is a single case.
    Thanks in advance for you help
    Regards
    Daniele
    Edited by: Danx on Jan 2, 2008 5:23 PM

    That message relates to how the application deals with its threads, which for a the most part isn't actually an issue. However, since it does have the potential to cause a leak under certain circumstances we did make a change in 10.3 to address that issue, so I suggest you upgrade to that release.

  • Memory Leak with 4.5.1/Java/Solaris

    Hi,
    We are currently running a Java Application using RMI/Weblogic 4.5.1/Solaris 5.7/Java 1.22.
    Behavior that has been observered during the day is that memory usage reaches a stage in which it begins increasing and GC doesn't recover any memory, until the heap reaches an extremly large size, then recovers a significant amount of memory.
    We have even seen the java process grab more memory than specified in the -Xmx parameter and experience a java.lang.OutOfMemory error.
    I have seen postings that describe similar issues in this newsgroup, but none that define a solution.
    This problem is intermittent, and our application can run an entire day without experiencing this memory leak. On the other hand there are days when the memory leak occurrs even when the system is idle overnight.
    Please let me know any information you have gathered on this subject.
    Regards,
    Mark Evans

    try increasing your virtual memory on your NT system...
    "Parasher K. Joshi" <[email protected]> wrote:
    >
    Hi,
    I observed the same confusing stuff in my tests. But I run weblogic 4.5.1 on Windows NT with JDK 1.2.2-w
    Usually, I would get a "Low virtual memory" message from windows
    and if I click ok & shuffle thourgh my windows I would be ok.
    But since last 2 days, I would keep the server running overnight.
    When I return in morning,
    I would find a "Low virtual memory" message and
    on clicking OK. I would find another message tell me that java.exe (which was running weblogic) crashed!!
    Now today I tried to watch the memory usage in Task Manager. And I found the most wierd thing.
    I saw that even when the system was doing virtually nothing,
    except print a string at intervals, the memory usage would go
    up steadyly.
    Even doing a forced finalization and gc did not seem to stop it.
    BUT, BY CHANCE I HAPPEN TO MINIMISE AND MAXIMISE THE WEBLOGIC
    CONSOLE OUTPUT WINDOW.
    WHAT I SAW IN THE TASK MANAGER AMAZED ME!
    THE MEMORY USAGE IN TASK MANAGER HAD GONE DOWN TO 24XXKB, WHILE
    IT WAS ABOUT 20000K OR EVEN MORE.
    This seems to support the fact that during my test, I would
    get the "low virtual memory" message and if OKed it and shuffled
    though application windows (maybe minimise, maximise the weblogic
    console output window in process), I would be able to complete
    my application. But when the message appears during night runs,
    nothing is done and by morning, when I reach to work,
    I would see that weblogic had crashed!!
    You may try that and see if it helps you.
    Parasher
    Mark Evans <[email protected]> wrote:
    Hi,
    We are currently running a Java Application using RMI/Weblogic 4.5.1/Solaris 5.7/Java 1.22.
    Behavior that has been observered during the day is that memory usage reaches a stage in which it begins increasing and GC doesn't recover any memory, until the heap reaches an extremly large size, then recovers a significant amount of memory.
    We have even seen the java process grab more memory than specified in the -Xmx parameter and experience a java.lang.OutOfMemory error.
    I have seen postings that describe similar issues in this newsgroup, but none that define a solution.
    This problem is intermittent, and our application can run an entire day without experiencing this memory leak. On the other hand there are days when the memory leak occurrs even when the system is idle overnight.
    Please let me know any information you have gathered on this subject.
    Regards,
    Mark Evans

  • Memory leak using thin client

    Subject: Memory Leak while using thin client.
    From: [email protected] (Alon Albert)
    Newsgroups: weblogic.developer.interest.jndi
    I have a small test program that causes a memory leak while connecting
    to a weblogic server. The code is appended to the end of the msg. The
    problem is definatly caused by the InitialContext creation.
    Even if I explicitly call the InitialContext.close() method, the
    problem persists. I realize I can avoid the problem by using a one
    time connection outside the loop but keep in mind that this is only a
    test program. The full application REQUIRES me to do a full
    reconnection each time it is accessed.
    I have read in a previous simmilar post that the problem mught be RMI
    related. Is anything I can do about this?
    package jmxleak;
    import java.net.*;
    import java.util.*;
    import javax.management.*;
    import javax.naming.*;
    public class Main {
    String host;
    String username;
    String password;
    MBeanServer mbs;
    public static void main(String[] args) {
    while (true) {
    Main main = new Main(args[0], args[1], args[2]);
    main.connect();
    main = null;
    System.out.println("Collecting garbage.");
    System.gc();
    public Main(String host, String username, String password) {
    this.host = host;
    this.username = username;
    this.password = password;
    private void connect() {
    try {
    System.out.print("Connecting..., ");
    Thread.currentThread().setContextClassLoader(new
    URLClassLoader(new URL[] { new URL("http://" + host + "/classes/")}));
    Hashtable env = new Hashtable();
    env.put("java.naming.factory.initial",
    "weblogic.jndi.WLInitialContextFactory");
    env.put("java.naming.provider.url", "t3://" + host);
    if (username.length() > 0 && password.length() > 0) {
    env.put("java.naming.security.principal", username);
    env.put("java.naming.security.credentials", password);
    System.out.print("Creating context..., ");
    InitialContext ctx = new InitialContext(env);
    catch (Exception e) {
    e.printStackTrace();

    Subject: Memory Leak while using thin client.
    From: [email protected] (Alon Albert)
    Newsgroups: weblogic.developer.interest.jndi
    I have a small test program that causes a memory leak while connecting
    to a weblogic server. The code is appended to the end of the msg. The
    problem is definatly caused by the InitialContext creation.
    Even if I explicitly call the InitialContext.close() method, the
    problem persists. I realize I can avoid the problem by using a one
    time connection outside the loop but keep in mind that this is only a
    test program. The full application REQUIRES me to do a full
    reconnection each time it is accessed.
    I have read in a previous simmilar post that the problem mught be RMI
    related. Is anything I can do about this?
    package jmxleak;
    import java.net.*;
    import java.util.*;
    import javax.management.*;
    import javax.naming.*;
    public class Main {
    String host;
    String username;
    String password;
    MBeanServer mbs;
    public static void main(String[] args) {
    while (true) {
    Main main = new Main(args[0], args[1], args[2]);
    main.connect();
    main = null;
    System.out.println("Collecting garbage.");
    System.gc();
    public Main(String host, String username, String password) {
    this.host = host;
    this.username = username;
    this.password = password;
    private void connect() {
    try {
    System.out.print("Connecting..., ");
    Thread.currentThread().setContextClassLoader(new
    URLClassLoader(new URL[] { new URL("http://" + host + "/classes/")}));
    Hashtable env = new Hashtable();
    env.put("java.naming.factory.initial",
    "weblogic.jndi.WLInitialContextFactory");
    env.put("java.naming.provider.url", "t3://" + host);
    if (username.length() > 0 && password.length() > 0) {
    env.put("java.naming.security.principal", username);
    env.put("java.naming.security.credentials", password);
    System.out.print("Creating context..., ");
    InitialContext ctx = new InitialContext(env);
    catch (Exception e) {
    e.printStackTrace();

  • Marshelling Web Service Response Memory Leak

    I believe I have found a memory leak when using the configuration below.
    The memory leak occurs when calling a web service. When the web service function is marshelling the response of the function call, an "500 Internal Server Error ... java.lang.OutOfMemoryError" is returned from OC4J. This error may be seen via the TCP Packet Monitor in JDeveloper.
    Unfortunately no exception dump is outputted to the OC4J log.
    Configuration:
    Windows 2000 with 1 gig ram
    JDeveloper 9.0.5.2 with JAX/RPC extension installed
    OC4J 10.0.3
    Sun JVM version 1.4.2_03-b02
    To demonstrate the error I created a simple web service and client. See below the client and web service function that demonstrates it.
    The web service is made up of a single function called "queryTestOutput".
    It returns an object of class "TestOutputQueryResult" which contains an int and an array.
    The function call accepts a one int input parameter which is used to vary the size of array in the returned object.
    For small int (less than 100). Web service function returns successfully.
    For larger int and depending on the size of memory configuration when OC4J is launched,
    the OutOfMemoryError is returned.
    The package "ws_issue.service" contains the web service.
    I used the Generate JAX-RPC proxy to build the client (found in package "ws_issue.client"). Package "types" was
    also created by Generate JAX-RPC proxy.
    To test the web service call execute the class runClient. Vary the int "atestValue" until error is returned.
    I have tried this with all three encodings: RPC/Encoded, RPC/Literal, Document/Literal. They have the
    same issue.
    The OutOfMemory Error is raised fairly consistently using the java settings -Xms386m -Xmx386m for OC4J when 750 is specified for the input parameter.
    I also noticed that when 600 is specified, the client seems to hang. According to the TCP Packet Monitor,
    the response is returned. But, the client seems unable to unmarshal the message.
    ** file runClient.java
    // -- this client is using Document/Literal
    package ws_issue.client;
    public class runClient
    public runClient()
    * @param args
    * Test out the web service
    * Play with the atestValue variable to until exception
    public static void main(String[] args)
    //runClient runClient = new runClient();
    long startTime;
    int atestValue = 1;
    atestValue = 2;
    //atestValue = 105; // last one to work with default memory settings in oc4j
    //atestValue = 106; // out of memory error as seen in TCP Packet Monitor
    // fails with default memory settings in oc4j
    //atestValue = 600; // hangs client (TCP Packet Monitor shows response)
    // when oc4j memory sessions are -Xms386m -Xmx386m
    atestValue = 750; // out of memory error as seen in TCP Packet Monitor
    // when oc4j memory sessions are -Xms386m -Xmx386m
    try
    startTime = System.currentTimeMillis();
    Ws_issueInterface ws = (Ws_issueInterface) (new Ws_issue_Impl().getWs_issueInterfacePort());
    System.out.println("Time to obtain port: " + (System.currentTimeMillis() - startTime) );
    // call the web service function
    startTime = System.currentTimeMillis();
    types.QueryTestOutputResponse qr = ws.queryTestOutput(new types.QueryTestOutput(atestValue));
    System.out.println("Time to call queryTestOutput: " + (System.currentTimeMillis() - startTime) );
    startTime = System.currentTimeMillis();
    types.TestOutputQueryResult r = qr.getResult();
    System.out.println("Time to call getresult: " + (System.currentTimeMillis() - startTime) );
    System.out.println("records returned: " + r.getRecordsReturned());
    for (int i = 0; i<atestValue; i++)
    types.TestOutput t = r.getTestOutputResults();
    System.out.println(t.getTestGroup() + ", " + t.getUnitNumber());
    catch (Exception e)
    e.printStackTrace();
    ** file wsmain.java
    package ws_issue.service;
    import java.rmi.RemoteException;
    import javax.xml.rpc.ServiceException;
    import javax.xml.rpc.server.ServiceLifecycle;
    public class wsmain implements ServiceLifecycle, ws_issueInterface
    public wsmain()
    public void init (Object p0) throws ServiceException
    public void destroy ()
    System.out.println("inside ws destroy");
    * create an element of the array with some hardcoded values
    private TestOutput createTestOutput(int cnt)
    TestOutput t = new TestOutput();
    t.setComments("here are some comments");
    t.setConfigRevisionNo("1");
    t.setItemNumber("123123123");
    t.setItemRevision("arev" + cnt);
    t.setTestGroup(cnt);
    t.setTestedItemNumber("123123123");
    t.setTestedItemRevision("arev" + cnt);
    t.setTestResult("testResult");
    t.setSoftwareVersion("version");
    t.setTestConditions("conditions");
    t.setStageName("world's a stage");
    t.setTestMode("Test");
    t.setTestName("test name");
    t.setUnitNumber("UnitNumber"+cnt);
    return t;
    * Web service function that is called
    * Create recCnt number of "records" to be returned
    public TestOutputQueryResult queryTestOutput (int recCnt) throws java.rmi.RemoteException
    System.out.println("Inside web service function queryTestOutput");
    TestOutputQueryResult r = new TestOutputQueryResult();
    TestOutput TOArray[] = new TestOutput[recCnt];
    for (int i = 0; i< recCnt; i++)
    TOArray = createTestOutput(i);
    r.setRecordsReturned(recCnt);
    r.setTestOutputResults(TOArray);
    System.out.println("End of web service function call");
    return r;
    * @param args
    public static void main(String[] args)
    wsmain wsmain = new wsmain();
    int aval = 5;
    try
    TestOutputQueryResult r = wsmain.queryTestOutput(aval);
    for (int i = 0; i<aval; i++)
    TestOutput t = r.getTestOutputResults();
    System.out.println(t.getTestGroup() + ", " + t.getUnitNumber());
    catch (Exception e)
    e.printStackTrace();
    ** file ws_issueInterface.java
    package ws_issue.service;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface ws_issueInterface extends java.rmi.Remote
    public TestOutputQueryResult queryTestOutput (int recCnt) throws java.rmi.RemoteException;
    ** file TestOutputQueryResult.java
    package ws_issue.service;
    public class TestOutputQueryResult
    private long recordsReturned;
    private TestOutput[] testOutputResults;
    public TestOutputQueryResult()
    public long getRecordsReturned()
    return recordsReturned;
    public void setRecordsReturned(long recordsReturned)
    this.recordsReturned = recordsReturned;
    public TestOutput[] getTestOutputResults()
    return testOutputResults;
    public void setTestOutputResults(TestOutput[] testOutputResults)
    this.testOutputResults = testOutputResults;
    ** file TestOutput.java
    package ws_issue.service;
    public class TestOutput
    private String itemNumber;
    private String itemRevision;
    private String configRevisionNo;
    private String testName;
    private String testConditions;
    private String stageName;
    private String testedItemNumber;
    private String testedItemRevision;
    private String unitNumber;
    private String testStation;
    private String testResult;
    private String softwareVersion;
    private String operatorID;
    private String testDate; // to be datetime
    private String comments;
    private int testGroup;
    private String testMode;
    public TestOutput()
    public String getComments()
    return comments;
    public void setComments(String comments)
    this.comments = comments;
    public String getConfigRevisionNo()
    return configRevisionNo;
    public void setConfigRevisionNo(String configRevisionNo)
    this.configRevisionNo = configRevisionNo;
    public String getItemNumber()
    return itemNumber;
    public void setItemNumber(String itemNumber)
    this.itemNumber = itemNumber;
    public String getItemRevision()
    return itemRevision;
    public void setItemRevision(String itemRevision)
    this.itemRevision = itemRevision;
    public String getOperatorID()
    return operatorID;
    public void setOperatorID(String operatorID)
    this.operatorID = operatorID;
    public String getSoftwareVersion()
    return softwareVersion;
    public void setSoftwareVersion(String softwareVersion)
    this.softwareVersion = softwareVersion;
    public String getStageName()
    return stageName;
    public void setStageName(String stageName)
    this.stageName = stageName;
    public String getTestConditions()
    return testConditions;
    public void setTestConditions(String testConditions)
    this.testConditions = testConditions;
    public String getTestDate()
    return testDate;
    public void setTestDate(String testDate)
    this.testDate = testDate;
    public String getTestName()
    return testName;
    public void setTestName(String testName)
    this.testName = testName;
    public String getTestResult()
    return testResult;
    public void setTestResult(String testResult)
    this.testResult = testResult;
    public String getTestStation()
    return testStation;
    public void setTestStation(String testStation)
    this.testStation = testStation;
    public String getTestedItemNumber()
    return testedItemNumber;
    public void setTestedItemNumber(String testedItemNumber)
    this.testedItemNumber = testedItemNumber;
    public String getTestedItemRevision()
    return testedItemRevision;
    public void setTestedItemRevision(String testedItemRevision)
    this.testedItemRevision = testedItemRevision;
    public String getUnitNumber()
    return unitNumber;
    public void setUnitNumber(String unitNumber)
    this.unitNumber = unitNumber;
    public int getTestGroup()
    return testGroup;
    public void setTestGroup(int testGroup)
    this.testGroup = testGroup;
    public String getTestMode()
    return testMode;
    public void setTestMode(String testMode)
    this.testMode = testMode;

    Many thanks for your help.  This solved the issue for our .NET code, however the leak is still present in the report designer.  I was also wondering if you could help further: because of the limits on the java memory process is there a way to ensure that a separate java process is started for each report that is loaded in my report viewers collection?  Essentially the desktop application that i have created uses a tab control to display each type report, so each tab goes through the following code when displaying a report and closing a tab:
    Is there a way to ensure that a different Java process is kicked off each time that I display a different report?  My current code in c# always uses the same Java process so the memory ramps up.  The code to load the report and then dispose of the report through closing the tab (and now the Java process) looks like this:
        private void LoadCrystalReport(string FullReportName)
          ReportDocument reportDoc = new ReportDocument();
          reportDoc.Load(FullReportName, OpenReportMethod.OpenReportByTempCopy);
          this.crystalReportViewer1.ReportSource = reportDoc;
        private void DisposeCrystalReportObject()
          if (crystalReportViewer1.ReportSource != null)
            ReportDocument report = (ReportDocument)crystalReportViewer1.ReportSource;
            foreach (Table table in report.Database.Tables)
              table.Dispose();
            report.Database.Dispose();
            report.Close();
            report.Dispose();
            GC.Collect();
    Thanks

  • Memory Leak in IPSec

    Hello,
    For my work i need to login with the Cisco VPN client. This works good, but sometimes i get a memory leak, and then my Mac get a Grey screen of death. The errorlog give the following error:
    +Mon Jun 2 13:56:05 2008+
    +panic(cpu 1 caller 0x001A8C8A): Kernel trap at 0x00197e36, type 14=page fault, registers:+
    +CR0: 0x8001003b, CR2: 0x03667004, CR3: 0x01177000, CR4: 0x00000660+
    +EAX: 0x12da7020, EBX: 0x00000014, ECX: 0x00000025, EDX: 0x00000094+
    +CR2: 0x03667004, EBP: 0x20e27e68, ESI: 0x03667004, EDI: 0x12da7020+
    +EFL: 0x00010212, EIP: 0x00197e36, CS: 0x00000008, DS: 0x00000010+
    +Error code: 0x00000000+
    +Backtrace, Format - Frame : Return Address (4 potential args on stack)+
    +0x20e27bf8 : 0x12b0f7 (0x4581f4 0x20e27c2c 0x133230 0x0)+
    +0x20e27c48 : 0x1a8c8a (0x461720 0x197e36 0xe 0x460ed0)+
    +0x20e27d28 : 0x19ece5 (0x20e27d40 0x50 0x20e27e68 0x197e36)+
    +0x20e27d38 : 0x197e36 (0xe 0x20e20048 0x10 0x21260010)+
    +0x20e27e68 : 0x2126a3c9 (0x20e27ed0 0x20e27ecc 0x20e27ed4 0x20e27ed8)+
    +0x20e27ef8 : 0x2154b4 (0x0 0x3260404 0x2 0x20e27f74)+
    +0x20e27f68 : 0x2158bb (0x0 0x1cf61700 0x0 0x31bc2ac)+
    +0x20e27fc8 : 0x19eadc (0x31bc284 0x0 0x1a20b5 0x2afe128)+
    +Backtrace terminated-invalid frame pointer 0+
    +Kernel loadable modules in backtrace (with dependencies):+
    com.cisco.nke.ipsec(2.0.1)@0x21268000->0x212d6fff
    +BSD process name corresponding to current thread: kernel_task+
    +Mac OS version:+
    9C7010
    +Kernel version:+
    +Darwin Kernel Version 9.2.2: Tue Mar 4 21:17:34 PST 2008; root:xnu-1228.4.31~1/RELEASE_I386+
    +System model name: MacBook3,1 (Mac-F22788C8)+
    IS this a bug in Mac OS X or into Cisco ?

    Why do you think it is a memory leak? It sounds like just a Cisco bug. There is a reason Cisco version numbers are 6 digits long. Try getting a newer version.

Maybe you are looking for