Memory leak in string class

We have developed our application in Solaris 10 environment. While running Purify on that it shows leak in the string class. This leak is incremental and so process size keeps in increasing. If we replace string with char array, the leaks disappears and process size also becomes stable.
Following is the snapshot of the memory leak stack reported by Purify:
MLK: 4505 bytes leaked in 85 blocks
* This memory was allocated from:
malloc [rtlib.o]
operator new(unsigned) [libCrun.so.1]
void*operator new(unsigned) [rtlib.o]
__rwstd::__string_ref<char,std::char_traits<char>,std::allocator<char> >*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::__getRep(unsigned,unsigned) [libCstd.so.1]
char*std::basic_string<char,std::char_traits<char>,std::allocator<char> >::replace(unsigned,unsigned,const char*,unsigned,unsigned,unsigned) [libCstd.so.1]
std::basic_string<char,std::char_traits<char>,std::allocator<char> >&std::basic_string<char,std::char_traits<char>,std::allocator<char> >::operator=(const char*) [libCstd.so.1]
Has anyone faced this problem earlier or is there any patch available for this?

Over time, we have found and fixed memory leaks in the C++ runtime libraries.
Get the latest patches for the compiler you are using. (You didn't say which one.) You can find all patches here:
[http://developers.sun.com/sunstudio/downloads/patches/index.jsp]
Also get the latest Solaris patch for the C++ runtime libraries, listed on the same web page.
If that doesn't fix the problem, please file a bug report at
[http://bugs.sun.com]
with a test case that can be compiled and run to demonstrate the problem.

Similar Messages

  • Memory leak in String(byte[] bytes, int offset, int length)

    Has anyone run into memory leak problem using this String(byte[] bytes, int offset, int length) class? I am using it to convert byte array to string, and I am showing memory leak using this class. Any idea what is going on?

    Hi,
    If you post in Native methods forum I assume you are using this constructor in the native side.
    Be aware that getting char * from jstring eats memory that you must free before returning from native with env->ReleaseStringUTFChars().
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Memory leak within FOProcessor class

    Hi all,
    I'm trying to use the XML Publisher API (5.6.2 and 5.6.3) to generate PDF documents from XSL templates and XML data in a J2EE environment (Jboss 4.0.5) with Struts but a memory leak occurs.
    It seems not to be a multithreading issue because the leak is there even if the PDF documents are generated one by one.
    I made many tests to isolate the leak and I have simplified my code as much as possible: it seems to happen within the FOProcessor class.
    One of the tests generates 4,500 PDF documents (one at a time) from an XML file (3 KB) and an XSL file (74 KB with blanks). Nothing else is done with the Jboss server during this test. The XSL file was created before the test from a RTF file with XML Publisher. The memory leak is around 70 KB for each PDF document (around 300 MB for the whole test).
    As you can see below from the heap histogram (taken at end of test after a full garbage collection) it seems that the XSL and XML elements/attributes are not released (and thus never garbage collected).
    Did I miss something or is there an actual problem with the XML/XSL parsing within the XML Publisher API?
    Thanks for your help.

    Object Histogram:
    Size    Count     Class description
    131376968 2353450 java.lang.Object[]
    60389464 937300  char[]
    48260304 335141  oracle.xml.parser.v2.XSLResultElement
    35690000 2230625 oracle.xml.util.FastVector
    24127104 1005296 java.lang.String
    16539120 413478  oracle.xml.parser.v2.XSLNode$AttrValueTmpl
    14757064 128058  int[]
    13348768 417149  java.lang.ref.Finalizer
    12701776 102220  * ConstMethodKlass
    12544808 23433   byte[]
    12204080 108965  oracle.xml.parser.v2.XSLText
    8344600 86584   java.util.Hashtable$Entry[]
    7363768 102220  * MethodKlass
    5592784 138700  * SymbolKlass
    5362256 335141  oracle.xml.parser.v2.XSLAttributeSet[]
    5267336 8135    * ConstantPoolKlass
    5234016 163563  java.util.TreeMap$Entry
    5121744 213406  java.util.Hashtable$Entry
    4900480 61256   oracle.xml.parser.v2.XPathStep
    4087120 51089   java.lang.reflect.Method
    3823216 40276   java.util.HashMap$Entry[]
    3524696 8135    * InstanceKlassKlass
    3378000 84450   java.util.Hashtable
    3064872 127703  java.util.HashMap$Entry
    2971904 6880    * ConstantPoolCacheKlass
    2968560 26505   oracle.xml.parser.v2.XSLValueOf
    2770656 24738   oracle.xml.parser.v2.XSLVariable
    2167520 27094   oracle.xml.parser.v2.XPathFunctionCall
    1880088 33573   oracle.xml.parser.v2.PathExpr
    1726360 61482   java.lang.String[]
    1573720 39343   java.util.HashMap
    1476576 30762   oracle.xml.parser.v2.XSLExprValue
    1460840 36521   java.util.TreeMap
    1319360 23560   oracle.xml.parser.v2.XPathConstantExpr
    1054976 16484   org.jboss.mx.server.InvocationContext
    1001264 3546    * MethodDataKlass
    887424  11049   short[]
    835680  8705    java.lang.Class
    830208  25944   oracle.xml.util.NSNameImpl
    705816  29409   java.util.ArrayList
    684152  4501    org.jboss.web.tomcat.tc5.session.SessionBasedClusteredSession
    670288  14071   java.lang.Object[]
    640832  10013   oracle.xml.parser.v2.XPathVarReference
    561056  35066   javax.management.modelmbean.DescriptorSupport
    556272  23178   EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap$Entry
    552984  30451   java.lang.Class[]
    494760  2945    oracle.xml.parser.v2.XSLTemplate
    480792  20033   antlr.ANTLRHashString
    442576  27661   java.lang.Integer
    432096  4501    org.jboss.web.tomcat.statistics.ReplicationStatistics$TimeStatistic
    429040  10726   org.hibernate.hql.ast.tree.Node
    369880  9247    javax.management.modelmbean.ModelMBeanOperationInfo
    312384  19524   java.util.TreeMap$3
    305368  5453    java.net.URL
    287392  8981    org.jboss.mx.interceptor.ReflectedDispatcher
    259264  338     EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap$Entry[]
    252280  4505    org.jboss.cache.lock.ReadWriteLockWithUpgrade
    238600  5965    org.jboss.mx.interceptor.PersistenceInterceptor
    238600  5965    org.jboss.mx.interceptor.AttributeDispatcher
    236616  9859    org.jboss.mx.server.AbstractMBeanInvoker$OperationKey
    219776  3434    java.lang.reflect.Constructor
    206880  6465    javax.management.modelmbean.ModelMBeanAttributeInfo
    193168  2259    java.lang.reflect.Method[]
    173184  5412    java.lang.ref.SoftReference
    164920  589     oracle.xml.parser.v2.XSLStylesheet
    164464  541     * ObjArrayKlassKlass
    152832  6368    org.dom4j.tree.DefaultAttribute
    149472  2076    java.lang.reflect.Field
    144160  4505    org.jboss.cache.Node
    143160  5965    org.jboss.mx.interceptor.ModelMBeanAttributeInterceptor
    140600  3515    org.apache.xerces.dom.DeferredTextImpl
    140224  2740    javax.management.modelmbean.ModelMBeanAttributeInfo[]
    139056  7658    boolean[]
    134664  3359    java.lang.String[][]
    131936  1178    oracle.xml.parser.v2.XSLCondition
    131936  1178    oracle.xml.parser.v2.XSLForEach
    129072  2668    javax.management.modelmbean.ModelMBeanOperationInfo[]
    128952  5373    EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap$Entry
    124776  1733    org.hibernate.hql.ast.tree.IdentNode
    115200  1800    javax.management.modelmbean.ModelMBeanInfoSupport
    113088  2356    oracle.xml.parser.v2.AdditiveExpr
    109416  4559    java.beans.PropertyChangeSupport
    108960  1135    java.io.ObjectStreamClass
    108120  4505    org.jboss.cache.lock.IdentityLock
    105864  345     long[]
    98752   3086    java.io.ObjectStreamClass$WeakClassKey
    97968   4082    java.util.Vector
    96672   2014    java.util.Properties
    94240   589     oracle.xml.parser.v2.XSLOutput
    90072   3753    javax.management.ObjectName$Property
    87432   3643    javax.management.MBeanParameterInfo
    82368   858     org.hibernate.hql.ast.tree.DotNode
    81248   5078    java.lang.Long
    78656   1229    org.hibernate.mapping.Column
    77664   4854    java.util.Collections$SynchronizedSet
    77448   3227    java.util.LinkedList$Entry
    73824   769     org.jboss.mx.modelmbean.XMBean
    73536   4596    java.util.Hashtable$KeySet
    72144   4509    EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet
    72144   4509    EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArrayList
    72144   4509    org.jboss.cache.Fqn
    72080   4505    org.jboss.cache.lock.ReadWriteLockWithUpgrade$WriterLock
    72080   4505    org.jboss.cache.lock.LockStrategyRepeatableRead
    72080   4505    org.jboss.cache.lock.ReadWriteLockWithUpgrade$ReaderLock
    72080   4505    org.jboss.cache.lock.LockMap
    72016   4501    org.apache.catalina.session.StandardSessionFacade
    71776   4486    java.io.FileDescriptor
    70680   589     oracle.xml.parser.v2.XSLCallTemplate
    70680   589     oracle.xml.parser.v2.XSLApplyTemplates
    70224   154     org.hibernate.persister.entity.SingleTableEntityPersister
    68296   2774    javax.management.ObjectName$Property[]
    68160   1065    org.apache.xerces.dom.DeferredElementNSImpl
    67760   770     org.hibernate.loader.entity.EntityLoader
    66992   19      EDU.oswego.cs.dl.util.concurrent.ConcurrentHashMap$Entry[]
    65968   1178    oracle.xml.parser.v2.XPathFilterExpr
    65968   589     oracle.xml.parser.v2.XMLUTF8Reader
    64432   4027    java.util.HashSet
    63648   1326    oracle.xml.parser.v2.XMLNode[]
    63440   1586    org.hibernate.loader.DefaultEntityAliases
    61256   589     oracle.xml.parser.v2.XSLNode
    61256   589     oracle.xml.parser.v2.XMLReader
    60816   2534    org.apache.xerces.xni.QName
    57360   478     org.hibernate.hql.ast.tree.FromElement
    56976   1187    org.hibernate.mapping.Property
    56544   1178    oracle.xml.parser.v2.XSLNodeSetExpr
    56544   1178    oracle.xml.parser.v2.MultiplicativeExpr
    56544   1178    oracle.xml.parser.v2.EqualExpr
    54384   618     oracle.xml.parser.v2.XMLError
    49392   2783    javax.management.MBeanParameterInfo[]
    47648   1489    java.util.LinkedHashMap$Entry
    47120   589     oracle.xml.parser.v2.XMLByteReader[]
    ...

  • Possible memory leak in TagFileTagInfo class

    Hello,
    Our application is experiencing a memory leak in Weblogic, which is not happening in other application servers.
    We are running Weblogic server 10.3 using the distributed jsf 1.2
    Eclipse Memory Analyzer clearly points to TagFileTagInfo class as retaining a Map which holds all the memory. Furthermore, it shows that said map (called _tagFileInfoMap) is holding FileTagFileInfo class instances.
    It could be possible that our application were doing something wrong, and that would cause the described behavior, however I doubt that as the other application servers where our application is deployed do not present this problem.
    Any suggestion on how we should proceed to fix this problem?
    Thanks
    Juan

    Hi,
    Was this issue resolved by using wlappc?
    Were you able to compile the tag files with wlappc? I tried compiling the jsps using wlappc, but it seems that the tool expects an ejb-jar file.
    Any help on this is greatly appreciated.
    Thanks
    Hareesh

  • Did the Java Writers Get a Little Happy with Memory Use in String class?

    I mean that question half jokingly.
    Taking a look at the String class code, I saw the following (below).
    Why is there an int for offset and an int for count?
    String is immutable, why not just return value.length for the count?
    And what is the offset for?
    Thanks!
    public final class String
        implements java.io.Serializable, Comparable<String>, CharSequence
        /** The value is used for character storage. */
        private final char value[];
        /** The offset is the first index of the storage that is used. */
        private final int offset;
        /** The count is the number of characters in the String. */
        private final int count;
        /** Cache the hash code for the string */
        private int hash; // Default to 0PS: a second look kinda verifies it too.
    in the constructor ,count is even defined as value.length.
        public String(char value[]) {
         int size = value.length;
         this.offset = 0;
         this.count = size;
         this.value = Arrays.copyOf(value, size);
        }

    You don't get the choice. The arrays are shared
    whenever you do substring.Yea, thats my point. I think most Strings are unique.
    Id be very surprised if even 2% of all String use was
    a result of a substring.The wrapper classes use it for parsing.
    File uses it for getName and getParent.
    String uses it for trim.
    Class uses it for resolving names.
    Regex uses it.
    etc. ...
    Now, I don't know what percentage of usage all that amounts to, but it IS heavily used.
    So your desire to gain the 2 bytes back would cost enough byte every time substring is used that it might end up costing far more than the 8 bytes you save.

  • Memory leak and char[] ?

    Hello all,
    I'm not sure whether this post should be here or in WebLogic section, so correct me if I'm wrong.
    I'm working on JDeveloper 11.1.1.3 while deployments are made on standalone WebLogic 10.3.3. This thing occurred in previous versions also.
    With every deployment WebLogic increases it's used memory until the famous PermGen space error, which is after about 5-6 deployments.
    I'm doing my best to understand how to use memleak detection tools. I've switched JDev and WL from Sun jdk which was used before to JRockit, same thing happens. Both JDev's memory profiler and JRockit mission control show something that I really do not understand. char[] uses around 30% of heap space and keeps growing with deployments, next is String with 8%. I never use char in app.
    Am I looking at the wrong thing? Is it normal for char[] to increase on WebLogic on deployments? Does anyone know how to check other things and what to check? Someone on other forums mentioned it would be useful to check if ApplicationContext keeps initializing over again on deployments. Does anyone know how to check this?
    One more thing, I have successfully deployed app on Tomcat, and Tomcat said there is a memory leak in app, but could not tell anything specific.
    I'm kinda lost in this :(

    It is normal for the PermGen space of the Sun's JVM to get filled after several re-deployments. PermGen stands for "permanent generational". This space is used by classes that is unlikely to need to be garbage-collected, so they are placed in this memory space that is never garbage-collected (for example, the Class instances). When you redeploy an application, a new class loader instance is used and it instantiates new Class instances that fill up the PermGen space. But why this happens on JRockit either, I could not explain.
    We have experienced memory leaks related to classes and components that use native memory. For example, we have had significant memory leak when using Oracle's JDBC OCI driver. We were not able to solve this problem, so we switched to JDBC Thin driver (which is very performant and stable today comparing to some years ago). If you are using Oracle JRockit, you can monitor the overall memory usage by the following JRockit command executed at OS command line:
    jrcmd <jrockit_pid> print_memusage>where <jrockit_pid> should be replaced by the JVM process ID.
    If you suspect existence of native memory leaks, then have a look at the article Thanks for the memory for explanations about how Java uses native memory.
    Dimitar

  • Memory Leak - again...

    Hello,
    Given the code snipppet below, will it generate a memory leak?.
    public class Dummy {
         public static List getList( String key){
                    List dList;
              dList = getAllDummyLists( key );
                    return dList;
                    //when this method exits, will dList be freed by GC?
    }Thank you!

    It depends on what getAllDummyLists does.
    It's difficult to find memory leaks by visual inspection. If it were easy, it wouldn't be a problem.
    If this is for work, the correct thing for you to do is to use a profiler.
    Edited by: paulcw on Nov 14, 2007 7:54 PM

  • Memory leaks with Third party classes

    Hello all,
    This is fairly known problem. But I guess, my problem gives a new dimention to the problem.
    I have an application which is developed by me. This application ideally needed to use third party classes ( obviously no source code is supplied ). These third party classes provide extra functionality required.
    The problem is, when I don't use third party classes in my application, every thing is fine. When I include third party classes, I am having memory leaks.
    Then I tried to investigate memory leaks with Optimizeit tool. It is new to me. As of now, I understood, we can identify where the memory leaks are occuring.
    finally the problem is, in order to solve this, I need some patches in the code. But I don't have source code for those classes. How to solve this problem?
    For example,
    I use a third party classes in my code like this,
    ThirdPartyMemoryLeakClass obj = new ThirdPartyMemoryLeakClass();
    This 'obj' is made static, as it takes lot of time to create this object. Obviously this object contains several references to other objects, which I can't control.
    In the process of reusing this object, I am getting memory leaks.
    Any ideas regarding, how one has to deal this type of situations? What are the issues involved with this case? Are there any similar problems, which have been solved? are most welcome.
    many thanks for your time.
    Madhav

    Decompile it using jad. Find leak.Yes, I too got the idea and tried to decompile those classes and recompile. I had some problems while recompiling. Is this is the only way to get rid of this problem?
    I was refering to powersoft.datawindow.DataStore class. Does any body here has worked on these?
    Can you suggest me how to find the memory leak causes? if you were needed to find out memory leak causes, what would be your approach?
    Madhav

  • Memory leak in Application

    Hi,
    we're load testing an application using Coherence. It uses a distributed cache, with an web application as the client, and separate cache servers implementing a Cache Store.
    We're getting several memory leaks and one area that was reported was a great number of instances for the com.tangosol.coherence.component.util.daemon.queueProcessor.service.DistributedCache$GetRequest class.
    Does anybody know what could cause these instances to be left hanging around? I think the Coherence classes ar a symptom of another problem rather than an issue with Coherence itself but it would be useful to know what could cause these objects to be left in the heap.
    Thanks
    Mike

    After further load testing, our application definitely seems to be leaking Coherence objects.
    The classes seem to be com.tangosol.util.Binary &
    com.tangosol.coherence.component.util.daemon.queueProcessor.service.DistributedCache$GetRequest.
    During testing, the number of Binary objects rose 0 to about 9000 and the number of GetRequest objects rose from 0 to about 3600 in two hours.
    The application stores objects in the cache and updates them, the main operation being to add to a very long log string required by the client to these objects, which represent sessions.
    Our test keeps a constant number of these objects in the cache during the run, removing the same number it creates after it has ramped up to full load testing.
    The application is stateless, it recieves frequent requests to get an object from the cache, work on it and put it back in the cache. The cache also has a cache store to persist the data to a database.
    Are there any references to the cache objects that would stop them being garbage collected?
    Our whole application is based in a simple stateless reqest/response operation and I cannot see where the huge number of objects is coming from.
    Mike

  • Memory leak in Tomcat 5.5

    Hi all, i am experiencing memory leaks while using tomcat 5.5 and mysql connector 3.1.7.. While running the attached code tomcat swallows up to 20 mb and doesnt return it. I close down everything but the app still leaks mem. For now it's not an issue (Tomcat stays below 60mb mem of 1gb), however running this app on serveral clients will dramatically increase the memory allocation.
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.awt.Image;
    import java.awt.Graphics2D;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import javax.swing.ImageIcon;
    import com.sun.image.codec.jpeg.JPEGCodec;
    import com.sun.image.codec.jpeg.JPEGImageEncoder;
    public class Thumbs extends HttpServlet {
      private String dbDriver = "com.mysql.jdbc.Driver";
      private String dbURL = "jdbc:mysql://localhost/webapp?";
      private String userID = "javauser";
      private String passwd = "javadude";
      private Connection dbConnection;
      //Initialize global variables
      public void init() throws ServletException {
      //Process the HTTP Get request
      public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try{
           String maxDim = "";
           String siteString = request.getParameterValues("s")[0];
           if (request.getParameterValues("d") != null){
               maxDim = request.getParameterValues("d")[0];
           if (maxDim == ""){
               response.setContentType("image/jpeg");
               OutputStream out = response.getOutputStream();
               writePicture(out,siteString);
           else{
               if (siteString != null) {
                   int maxDimension = Integer.parseInt(maxDim);
                   response.setContentType("image/jpeg");
                   OutputStream out = response.getOutputStream();
                   writeThumbnailPicture(out, siteString, maxDimension);
        } catch (Exception ex){
            ex.printStackTrace();
            log(ex.getMessage());
      public void writePicture(OutputStream out, String siteID){
          try{
              Class.forName(dbDriver);
              dbConnection = DriverManager.getConnection(dbURL, userID, passwd);
              PreparedStatement stmt = dbConnection.prepareStatement("select * from webcatalog where ID = ?");
              stmt.setString(1,siteID);
              stmt.executeQuery();
              ResultSet rs = stmt.getResultSet();
              if (rs.next()) {
                  byte[] data = rs.getBytes("Picture");
                  if (data != null) {
                      Image inImage = new ImageIcon(data).getImage();
                      BufferedImage outImage = new BufferedImage(inImage.getWidth(null),
                                                                 inImage.getHeight(null),
                                                                 BufferedImage.TYPE_INT_RGB);
                      // Paint image.
                      Graphics2D g2d = outImage.createGraphics();
                      g2d.drawImage(inImage,null,null);
                      // JPEG-encode the image
                      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                      encoder.encode(outImage);
                      out.close();
              rs.close();
              stmt.close();
              dbConnection.close();
          }catch(Exception ex){
              ex.printStackTrace();
      public void writeThumbnailPicture(OutputStream out,String siteID,int maxDimension){
        try{
          Class.forName(dbDriver);
          dbConnection = DriverManager.getConnection(dbURL, userID, passwd);
          PreparedStatement stmt = dbConnection.prepareStatement("select * from webcatalog where ID = ?");
          stmt.setString(1,siteID);
          stmt.executeQuery();
          ResultSet rs = stmt.getResultSet();
          if (rs.next()) {
            byte[] data = rs.getBytes("Picture");
            if (data != null) {
              Image inImage = new ImageIcon(data).getImage();
              // Determine the scale.
               double scale = (double)maxDimension / (double)inImage.getHeight(null);
               if (inImage.getWidth(null) > inImage.getHeight(null)) {
                   scale = (double)maxDimension /(double)inImage.getWidth(null);
               // Determine size of new image.
               // One of them should equal maxDim.
               int scaledW = (int)(scale*inImage.getWidth(null));
               int scaledH = (int)(scale*inImage.getHeight(null));
               // Create an image buffer in
               //which to paint on.
               BufferedImage outImage = new BufferedImage(scaledW, scaledH,
                   BufferedImage.TYPE_INT_RGB);
               // Set the scale.
               AffineTransform tx = new AffineTransform();
               // If the image is smaller than
               // the desired image size,
               // don't bother scaling.
               if (scale < 1.0d) {
                   tx.scale(scale, scale);
               // Paint image.
               Graphics2D g2d = outImage.createGraphics();
               g2d.drawImage(inImage, tx, null);
               g2d.dispose();
               // JPEG-encode the image
               JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
               encoder.encode(outImage);
               out.close();
          rs.close();
          stmt.close();
          dbConnection.close();
        catch(Exception ex){
          ex.printStackTrace();
      //Clean up resources
      public void destroy() {
      private void jbInit() throws Exception {
    }

    you can try this:
    open your connection outside the function, and then pass it like as a parameter...
    writePicture(OutputStream out, String siteID, Connection conn)
    this can solve the problem because opening the connection inside the function spends a lot of memory...
    Hope this can help you
    Regards
    Fernando

  • Memory Leak issue with TreeView

    Hi,
    I get Memory Leaks in the TreeView, if I open the stage which contains the TreeView several times.
    Everytime I open the stage, I clear the TreeView and populate it with new items.
    However there are leaks.
    I think this is a bug. But maybe my code is wrong and someone could comment on this issue.
    See this test case:
    i < 10: 5854 KB
    i < 100: 35944 KB
    i < 200: 64515 KB
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.TreeItem;
    import javafx.scene.control.TreeView;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    import javafx.stage.WindowEvent;
    public class TestApp3 extends Application {
        public static void main(String[] args) throws Exception {
            launch(args);
        public void start(final Stage stage) throws Exception {
            VBox root = new VBox();
            SubStage subStage = new SubStage();
            for (int i = 0; i < 10; i++) {
                subStage.show();
                subStage.hide();
            System.gc();
            System.out.println((Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 + " KB");
            Scene scene = new Scene(root);
            stage.setScene(scene);
            stage.show();
        private class SubStage extends Stage {
            public SubStage() {
                TreeView<String> treeView = new TreeView<String>();
                final TreeItem<String> rootNode = new TreeItem<String>("Root");
                treeView.setRoot(rootNode);
                setOnShowing(new EventHandler<WindowEvent>() {
                    @Override
                    public void handle(WindowEvent windowEvent) {
                        rootNode.getChildren().clear();
                        rootNode.getChildren().add(new TreeItem<String>("Item"));
                Scene scene = new Scene(treeView);
                setScene(scene);
    }Edited by: csh on 07.09.2012 06:14
    Edited by: csh on 07.09.2012 06:14

    Hi. If You replace
        rootNode.getChildren().clear();
        rootNode.getChildren().add(new TreeItem<String>("Item"));
      with:
         rootNode.getChildren().setAll( new TreeItem<String>("Item"));
    You will get the following:
    i < 10: 2881 KB
    i < 100: 3341 KB
    I <200: 3478 KB

  • Memory leak in weblogic 6.0 sp2 oracle 8.1.7 thin driver

    Hi,
         I have a simple client that opens a database connection, selects from
    a table containing five rows of data (with four columns in each row)
    and then closes all connections. On running this in a loop, I get the
    following error after some time:
    <Nov 28, 2001 5:57:40 PM GMT+06:00> <Error> <Adapter>
    <OutOfMemoryError in
    Adapter
    java.lang.OutOfMemoryError
    <<no stack trace available>>
    >
    <Nov 28, 2001 5:57:40 PM GMT+06:00> <Error> <Kernel> <ExecuteRequest
    failed
    java.lang.OutOfMemoryError
    I am running with a heap size of 64 Mb. The java command that runs
    the client is:
    java -ms64m -mx64m -cp .:/opt/bea/wlserver6.0/lib/weblogic.jar
    -Djava.naming.f
    actory.initial=weblogic.jndi.WLInitialContextFactory
    -Djava.naming.provider.url=
    t3://garlic:7001 -verbose:gc Test
    The following is the client code that opens the db connection and does
    the select:
    import java.util.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.*;
    public class Test {
    private static final String strQuery = "SELECT * from tblPromotion";
    public static void main(String argv[])
    throws Exception
    String ctxFactory     = System.getProperty
    ("java.naming.factory.initial");
    String providerUrl     = System.getProperty
    ("java.naming.provider.url");
    Properties jndiEnv          = System.getProperties ();
    System.out.println ("ctxFactory : " + ctxFactory);
    System.out.println ("ProviderURL : " + providerUrl);
    Context ctx     = new InitialContext (jndiEnv);
    for (int i=0; i <1000000; i++)
    System.out.println("Running query for the "+i+" time");
    Connection con = null;
    Statement stmnt = null;
    ResultSet rs     = null;
    try
    DataSource ds     = (DataSource) ctx.lookup
    (System.getProperty("eaMDataStore", "jdbc/eaMarket"));
    con = ds.getConnection ();
    stmnt = con.createStatement();
    rs = stmnt.executeQuery(strQuery);
    while (rs.next ())
    //System.out.print(".");
    //System.out.println(".");
    ds = null;
    catch (java.sql.SQLException sqle)
    System.out.println("SQL Exception : "+sqle.getMessage());
    finally
    try {
    rs.close ();
    rs = null;
    //System.out.println("closed result set");
    } catch (Exception e) {
    System.out.println("Exception closing result set");
    try {
    stmnt.close ();
    stmnt = null;
    //System.out.println("closed statement");
    } catch (Exception e) {
    System.out.println("Exception closing result set");
    try {
    con.close();
    con = null;
    //System.out.println("closed connection");
    } catch (Exception e) {
    System.out.println("Exception closing connection");
    I am using the Oracle 8.1.7 thin driver. Please let me know if this
    memory leak is a known issue or if its something I am doing.
    thanks,
    rudy

    Repost in JDBC section ... very serious issue but it may be due to Oracle or
    to WL ... does it happen if you test inside WL itself?
    How many iterations does it take to blow? How long? Does changing to a
    different driver (maybe Cloudscape) have the same result?
    Peace,
    Cameron Purdy
    Tangosol Inc.
    << Tangosol Server: How Weblogic applications are customized >>
    << Download now from http://www.tangosol.com/download.jsp >>
    "R.C." <[email protected]> wrote in message
    news:[email protected]...
    Hi,
    I have a simple client that opens a database connection, selects from
    a table containing five rows of data (with four columns in each row)
    and then closes all connections. On running this in a loop, I get the
    following error after some time:
    <Nov 28, 2001 5:57:40 PM GMT+06:00> <Error> <Adapter>
    <OutOfMemoryError in
    Adapter
    java.lang.OutOfMemoryError
    <<no stack trace available>>
    >
    <Nov 28, 2001 5:57:40 PM GMT+06:00> <Error> <Kernel> <ExecuteRequest
    failed
    java.lang.OutOfMemoryError
    I am running with a heap size of 64 Mb. The java command that runs
    the client is:
    java -ms64m -mx64m -cp .:/opt/bea/wlserver6.0/lib/weblogic.jar
    -Djava.naming.f
    actory.initial=weblogic.jndi.WLInitialContextFactory
    -Djava.naming.provider.url=
    t3://garlic:7001 -verbose:gc Test
    The following is the client code that opens the db connection and does
    the select:
    import java.util.*;
    import java.sql.*;
    import javax.naming.*;
    import javax.sql.*;
    public class Test {
    private static final String strQuery = "SELECT * from tblPromotion";
    public static void main(String argv[])
    throws Exception
    String ctxFactory = System.getProperty
    ("java.naming.factory.initial");
    String providerUrl = System.getProperty
    ("java.naming.provider.url");
    Properties jndiEnv = System.getProperties ();
    System.out.println ("ctxFactory : " + ctxFactory);
    System.out.println ("ProviderURL : " + providerUrl);
    Context ctx = new InitialContext (jndiEnv);
    for (int i=0; i <1000000; i++)
    System.out.println("Running query for the "+i+" time");
    Connection con = null;
    Statement stmnt = null;
    ResultSet rs = null;
    try
    DataSource ds = (DataSource) ctx.lookup
    (System.getProperty("eaMDataStore", "jdbc/eaMarket"));
    con = ds.getConnection ();
    stmnt = con.createStatement();
    rs = stmnt.executeQuery(strQuery);
    while (rs.next ())
    //System.out.print(".");
    //System.out.println(".");
    ds = null;
    catch (java.sql.SQLException sqle)
    System.out.println("SQL Exception : "+sqle.getMessage());
    finally
    try {
    rs.close ();
    rs = null;
    //System.out.println("closed result set");
    } catch (Exception e) {
    System.out.println("Exception closing result set");
    try {
    stmnt.close ();
    stmnt = null;
    //System.out.println("closed statement");
    } catch (Exception e) {
    System.out.println("Exception closing result set");
    try {
    con.close();
    con = null;
    //System.out.println("closed connection");
    } catch (Exception e) {
    System.out.println("Exception closing connection");
    I am using the Oracle 8.1.7 thin driver. Please let me know if this
    memory leak is a known issue or if its something I am doing.
    thanks,
    rudy

  • Memory Leak In DataService

    Hi All,
          I had posted this query to couple of other groups ..I am still struglling with this issue..Hope someone  will  help me out here
          I have  very basic application which uses  DataSerives over RTMP channel  to populate dataGrid , I have not used any  user defined component.
    This application has got LOAD data and Remove data  Button just to simulate the actual application
    What happens , when I click on LOAD data , It  loads the data from server(JBOSS) then I Remove all the data and force the GC to run
    If I continuously keep loading and removing the  data ,  memory goes up every time and after some times It reaches to threshold and  finally crashes the Browser.
    In actual application as soon as user logs in a dedicated DS destination is created..
        private function createDestination(destName:String):void{
                 var remoteService:RemoteObject = new RemoteObject("DestinationManager");
                 remoteService.addEventListener(ResultEvent.RESULT, resultHandler,false,0,true);
                 var operation:AbstractOperation = remoteService.getOperation("createDestination");
                 operation.send(destName);
                 var cs:ChannelSet = new ChannelSet();
                 var rtmpChannel:RTMPChannel = ServerConfig.getChannel("my-rtmp") as  RTMPChannel;
                 cs.addChannel(rtmpChannel);
                 tradeService = new DataService() ;
                 tradeService.destination=destName;
                 tradeService.channelSet = cs;  
    Now when user hits on Load data button to load the trade data ...
       public function loadData():void
             var remoteService:RemoteObject  = new RemoteObject("filterRemoteVO");
             var operation:AbstractOperation = remoteService.getOperation("loadData");
             tradeService.fill(tradeCollection);
             operation.send(rowData.text ,GUIID);
             tradeList.dataProvider = tradeCollection;
    Remove Data  hit I clean all the resource and released collection :-
          public  function  removeAll():void{
             if(tradeList.dataProvider){
                  tradeCollection.source = new Array();
                  tradeList.dataProvider.source = new Array();
                  tradeList.dataProvider = null;
                tradeService.release();
               tradeService.releaseCollection(tradeCollection);
              tradeService.channelSet.disconnectAll();
              tradeService.disconnect();
               tradeService.logout();
               System.gc();
    Except these 3 function I don't have any code which could cause memory leak.
    I m using
    LCDS 2.5
    Flex 3.0
    JBoss4.2
    Please see the mxml file below   , If  possible please have a look at it , I might  not be using dataSerice API correctly.
    I have been trying to solve this leak for last two week , I really need help from you guys.
    My client has already evaluating other contemporary technology because of this memory issue.
    I have also created scalled down war file which can be deployed on any  java application server.
    Any help will greatly be appreciated
    Regards,
    Dam
    ######################## MXML##########################
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
          creationComplete="init();" height="100%" width="100%"
         >
         <mx:Script >
         <![CDATA[
             import mx.containers.GridRow;
               import mx.utils.Base64Decoder;
             import mx.utils.StringUtil;
                import mx.events.CollectionEvent;
             import mx.formatters.Formatter;
             import mx.events.ResizeEvent;
             import mx.controls.DataGrid;
             import mx.effects.Fade;
             import mx.events.DataGridEvent;
             import mx.utils.ObjectUtil;
             import mx.events.ScrollEvent;
           import mx.formatters.DateFormatter;
           import mx.events.ListEvent;
           import mx.data.mxml.DataService;
           import mx.messaging.config.ServerConfig;
           import mx.messaging.channels.RTMPChannel;
           import mx.messaging.ChannelSet;
           import mx.rpc.AbstractOperation;
           import mx.rpc.remoting.RemoteObject;
           import mx.collections.ArrayCollection;
           import mx.controls.Alert;
           import mx.rpc.events.ResultEvent;
           import mx.messaging.messages.*;
           import mx.messaging.events.*;
           import mx.controls.Alert;
            private var GUIID:String;
            private var lastRollOverIndex:Number;
            public var tradeService:DataService=null;
            public var tradeCollection:ArrayCollection = new ArrayCollection();
           public var flag:Boolean = false;
            private function init():void {
               var guiId:String ="TEST";
                createDestination(GUIID);
            public function getData():void{
                 // memory.text =""+ ((System.totalMemory / 1024)/1024);
            public function releaseDataServices():void {
               //  tradeService.fill(null);
                    tradeService.release();
                   // tradeService.releaseCollection(tradeCollection);
                   tradeService.channelSet.disconnectAll();
                    tradeService.disconnect();
                    tradeService.logout();
                    //tradeService.dataStore = null;
                    /*Function for creating destination*/
              private function createDestination(destName:String):void{
                 var remoteService:RemoteObject = new RemoteObject("DestinationManager");
                 remoteService.addEventListener(ResultEvent.RESULT, resultHandler,false,0,true);
                 var operation:AbstractOperation = remoteService.getOperation("createDestination");
                 operation.send(destName);
                 var cs:ChannelSet = new ChannelSet();
                 var rtmpChannel:RTMPChannel = ServerConfig.getChannel("my-rtmp") as RTMPChannel;
                 cs.addChannel(rtmpChannel);
                 tradeService = new DataService() ;
                 tradeService.destination=destName;
                 tradeService.channelSet = cs;  
             //This function calls dataservice fill method depending on wheather destination is created or not
            private function resultHandler(event:ResultEvent):void{
               //call data service as destination is created successfully
                var status:Boolean = event.result as Boolean
               // Alert.show("status="+status);
                if(status){
                 getData();
               else{
                   //TODO report error to MATS app  
          public  function  removeAll():void{
             if(tradeList.dataProvider){
                  tradeCollection.source = new Array();
                  tradeList.dataProvider.source = new Array();
                  tradeList.dataProvider = null;
                tradeService.release();
               // tradeService.releaseCollection(tradeCollection);
              tradeService.channelSet.disconnectAll();
              tradeService.disconnect();
               tradeService.logout();
               System.gc();
           public function loadData():void
             var remoteService:RemoteObject  = new RemoteObject("filterRemoteVO");
             var operation:AbstractOperation = remoteService.getOperation("loadData");
             tradeService.fill(tradeCollection);
             operation.send(rowData.text ,GUIID);
             tradeList.dataProvider = tradeCollection;
       ]]>
    </mx:Script>
          <mx:DataGrid   id="tradeList"
                 initialize="tradeList.dataProvider = tradeCollection" horizontalScrollPolicy="auto"
                   height="659" x="0" y="84">
                <mx:columns>
                     <mx:DataGridColumn  headerText="Security Description" dataField="securityDesc"
                      />
                     <mx:DataGridColumn  headerText="B/S" dataField="transactionType"
                     />
                     <mx:DataGridColumn  headerText="Amount" dataField="amount"
                     />
                     <mx:DataGridColumn  headerText="Price Text" dataField="priceText"
                     />
                     <mx:DataGridColumn  headerText="Counterparty" dataField="counterParty"
                     />
                     <mx:DataGridColumn  headerText="Trade Date" dataField="tradeDate"
                     />
                     <mx:DataGridColumn  headerText="Settle Date" dataField="settleDate"
                     />
                     <mx:DataGridColumn  headerText="Trade Status" dataField="tradeStatusId"
                     />
                     <mx:DataGridColumn  headerText="Trader" dataField="trader"
                     />
                     <mx:DataGridColumn  headerText="Salesperson" dataField="salesperson"
                     />
                     <mx:DataGridColumn  headerText="Ticket Number" dataField="tradeNumber"
                     />
                     <mx:DataGridColumn  headerText="Entry Date" dataField="tradeTime"
                     />
                     <mx:DataGridColumn  headerText="Cancel Date" dataField="cancelDate"
                     />
                     <mx:DataGridColumn  headerText="Cancel Time" dataField="cancelTime"
                     />
                 </mx:columns>
              </mx:DataGrid >
             <mx:Grid x="149" y="23" width="995">
                     <mx:GridRow width="100%" height="100%">
                                <mx:GridItem width="100%" height="100%">
                                     <mx:Label text="Enter No of obejcts"   width="111"/>
                             </mx:GridItem>
                             <mx:GridItem width="100%" height="100%">
                                     <mx:TextInput name="row" id="rowData"   width="97"/>
                             </mx:GridItem>
                             <mx:GridItem width="100%" height="100%">
                                     <mx:Button  label="Load Data" click='loadData()'/>
                             </mx:GridItem>
                             <mx:GridItem width="100%" height="100%">
                                     <mx:Button  label="removeAll" click='removeAll()'/>
                             </mx:GridItem>
                             <mx:GridItem width="100%" height="100%">
                                     <mx:Label text="Total Memory"/>
                             </mx:GridItem>
                             <mx:GridItem width="100%" height="100%">
                                     <mx:TextInput text="Total Memory" id="memory"   width="97"/>
                             </mx:GridItem>
                             <mx:GridItem width="100%" height="100%">
                                     <mx:Label text="Grid Row Count"/>
                             </mx:GridItem>
                             <mx:GridItem width="100%" height="100%">
                                     <mx:TextInput name="GridRowCountN" id="GridRowCount"   width="97"/>
                             </mx:GridItem>
                     </mx:GridRow>
             </mx:Grid>
    </mx:Application>

    Hi Natasha,
    Sorry for late reply.
          I tried your suggestion but It did not help to release memory. Actully,this app contains only one event handler which is for remote method call , I dont think this could cause any memory leak.
    Profiling session reveals that It is the issue of DataService class.I dont know How do I convince  Adobe to investigate this issue.
    Regards,
    Dharmendra

  • Memory Leak in BI SDK with XMLA Connector ?

    Hi,
    I am using BI SDK 3.5 with XMLA Connector. I noticed that in com.sap.ip.bi.sdk.dac.connector.xmla.impl.Connection class, the LocalTransaction object is rollbacked when the close() method is called.
    This makes a call to the endTransaction() method of Repository class with "true" parameter and leads to informations storage into a RepositoryDBMemory instance.
    The only way I found to avoid this is to call the endTransaction() method with "false" as parameter, which is what is done in commit() method of the LocalTransaction class.
    So, I tried to commit the transaction before closing the connection but in XMLA mode, the getLocalTransaction() method throws an BIResourceException so it is impossible to commit it. This is the first issue.
    Second issue: it seems that data hold by the DataSetContentHandler is not freed. I tried using SAP Parser, Xerces, Java Parser but it has no effect. I hava a MDX query that returns 13000 lines, the XML file size is about 15Mo.
    In a for loop with 10 operations, it leads to a OutOfMemory error quickly (only 7 iterations OK with -Xmx256m -Xms256m options). On each iteration, the memory grows about 25 to 30Mo !
    For the first point, I do not call the close method on the connection object and it is garbage collected (but, in my opinion, it is quite strange not calling the close() method on a connection object).
    For the second one (DataSetContentHandler), I have no idea. Has someone already encounter this problem ? The Netbeans profiler tells me it is this object that holds all java.lang.String objects. Is it right ?
    I saw in DataSetContentHandler class that it has two static fields: one for the row cursor of the dataset, the other one for column cursor. Why ? Is it OK in a multi-threaded context ?
    <b>This is urgent as we will not put the project in production mode with such a memory leak ! We must find the problem very quickly.</b>
    Thanks in advance for any help you might give to me !
    Regards,
    David Degardin (Ubik-Ingenierie)

    I found the same thing. Tracing the execution back I found the only place this function was called was as part of the setup, so you shouldn't have to worry about it getting called multiple times and leaking memory. The trouble seems to be when the AudioPlayer dealloc method is called, the memory is not cleaned up.
    My fix was to modify the dealloc in AudioQueueObject to check to see if audioLevels is nil and, if not, free it. This seems to have fixed the problem.

  • Memory Leak with new Font()

    Hello all,
    Not sure if this is the right place to post this but here goes. I have a program that needs to change the font of at least 250,000 letters, however after doing this the program runs slow and laggy as if changing the fonts of each letter took up memory and never released it? Here is a compilable example, Click the button at the bottom of the window and watch the letter it is currently working on. You will notice that around 200,000 it will begin to not smoothly count up anymore but count in kind of a skipping pattern. This seems to get worse the more you do it and seems to indicate to me that something is using memory and not releasing it. I'm not sure why replacing a letter's font with a new font would cause more memory to be taken up I would think if I was doing it properly it would simply replace the old font with the new one not taking anymore memory then it did before. Here is the example: This program sometimes locks up so be prepared. If someone could maybe point out what is causing this to take up more memory after changing the fonts that would be great and hopefully find a solution :) Thanks in advance.
    -neptune692
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package paintsurface;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import java.util.List;
    public class PaintSurface implements Runnable, ActionListener {
    public static void main(String[] args) {
            SwingUtilities.invokeLater(new PaintSurface());
    List<StringState> states = new ArrayList<StringState>();
    Tableaux tableaux;
    Random random = new Random();
    Font font = new Font("Arial",Font.PLAIN,15);
    //        Point mouselocation = new Point(0,0);
    static final int WIDTH = 1000;
    static final int HEIGHT = 1000;
    JFrame frame = new JFrame();
    JButton add;
    public void run() {
            tableaux = new Tableaux();
            for (int i=250000; --i>=0;)
                    addRandom();
            frame.add(tableaux, BorderLayout.CENTER);
            add = new JButton("Change Font of letters - memory leak?");
            add.addActionListener(this);
            frame.add(add, BorderLayout.SOUTH);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(WIDTH, HEIGHT);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    public void actionPerformed(ActionEvent e) {
        new Thread(new ChangeFonts()).start();
    void addRandom() {
            tableaux.add(
                            Character.toString((char)('a'+random.nextInt(26))),
                            UIManager.getFont("Button.font"),
                            random.nextInt(WIDTH), random.nextInt(HEIGHT));
    //THIS CLASS SEEMS TO HAVE SOME KIND OF MEMORY LEAK I'M NOT SURE?
    class ChangeFonts implements Runnable {
        public void run() {
        Random rand = new Random();
            for(int i = 0; i<states.size(); i++) {
                font = new Font("Arial",Font.PLAIN,rand.nextInt(50));
                states.get(i).font = font;
                add.setText("Working on letter - "+i);
    class StringState extends Rectangle {
            StringState(String str, Font font, int x, int y, int w, int h) {
                    super(x, y, w, h);
                    string = str;
                    this.font = font;
            String string;
            Font font;
    class Tableaux extends JComponent {
            Tableaux() {
                    this.enableEvents(MouseEvent.MOUSE_MOTION_EVENT_MASK);
                    lagState = createState("Lag", new Font("Arial",Font.BOLD,20), 0, 0);
            protected void processMouseMotionEvent(MouseEvent e) {
                    repaint(lagState);
                    lagState.setLocation(e.getX(), e.getY());
                    repaint(lagState);
                    super.processMouseMotionEvent(e);
            StringState lagState;
            StringState createState(String str, Font font, int x, int y) {
                FontMetrics metrics = getFontMetrics(font);
                int w = metrics.stringWidth(str);
                int h = metrics.getHeight();
                return new StringState(str, font, x, y-metrics.getAscent(), w, h);
            public void add(String str, Font font, int x, int y) {
                    StringState state = createState(str, font, x, y);
                    states.add(state);
                    repaint(state);
            protected void paintComponent(Graphics g) {
                    Rectangle clip = g.getClipBounds();
                    FontMetrics metrics = g.getFontMetrics();
                    for (StringState state : states) {
                            if (state.intersects(clip)) {
                                    if (!state.font.equals(g.getFont())) {
                                            g.setFont(state.font);
                                            metrics = g.getFontMetrics();
                                    g.drawString(state.string, state.x, state.y+metrics.getAscent());
                    if (lagState.intersects(clip)) {
                    g.setColor(Color.red);
                    if (!lagState.font.equals(g.getFont())) {
                        g.setFont(lagState.font);
                        metrics = g.getFontMetrics();
                    g.drawString("Lag", lagState.x, lagState.y+metrics.getAscent());
    }Here is the block of code that I think is causing the problem:
    //THIS CLASS SEEMS TO HAVE SOME KIND OF MEMORY LEAK I'M NOT SURE?
    class ChangeFonts implements Runnable {
        public void run() {
        Random rand = new Random();
            for(int i = 0; i<states.size(); i++) {
                font = new Font("Arial",Font.PLAIN,rand.nextInt(50));
                states.get(i).font = font; // this line seems to cause the problem?
                add.setText("Working on letter - "+i);
    }

    neptune692 wrote:
    jverd wrote:
    You're creating a quarter million distinct Font objects, and obviously you must be hanging on to all of them because each character is having its font set to the newly created object. So if you have 250k chars, you're forcing it to have 250k Font objects.
    Since the only difference is that rand.nextInt(50) parameter, just pre-create 50 Font objects with 0..49, stick 'em in the corresponding elements in an array, and use rand.nextInt to select the Font object to use.That does make sense but it does that when the the program is first launched and doesn't lag. But the second and third time you change the letters font it seems to lag so if it wasn't taking up more memory the second time it should perform like it did when it first launched. I don't care to investigate any further. The real problem is almost certainly the quarter million Font objects. It could be that 250k is fine, but by the time you get to 500k, it has to do a lot of GC, and that's where the slow down is coming. You might even be able to make it work better with the code you have just by tweaking the GC parameters at startup, but I wouldn't bother. Fix the code first, and then see if you have issues.
    Does creating a new font for each of those letters not replace the old font object? If it didn't use more memory the second and third time I don't think you would see the skipping in the counter and the slowing down of the iterations. So it must be remembering some of the old font objects or am I wrong?Using new always creates a new object. When you do it the second time around, and call letter.setFont(newFont), the old Font object is eligible for GC. That doesn't mean it will be GCed right away though. The JVM can leave them all laying around until it runs out of memory, and then GC some or all of them.

Maybe you are looking for

  • Exception handling in rfcs and bapis

    exception handling in rfcs and bapis

  • Print pdf files on a A4 format

    Dear all, When I want to print my pdf files on a A4 format- one page per paper, the document is printed on the half of the paper. I encounter this problem on the Acrobat Adobe X series, hence it was not the case with previous editions of Acrobat Read

  • /usr/sfw/sbin/snmpd core dump with 6 local Zones

    Hi, the snmpd is running in 8 local and 1 global zone. If I do the following command from our monitoring server the snmpd crashes with a core dump in / in the global zone. /usr/sfw/bin/snmpdf -v 2c -c public servername I have all the lates patches ap

  • Postings in wrong Functional Area

    Hi, I have a complicated scenario, i have a service purchase order for a cost center C111 which as a Functional Area F101, during invoice i had changed the cost center to C222 and changed the Functional Area to F101, where the cost center C222 belong

  • I am looking functioanl specification

    Hi Guru's I am looking functioanl specification on following 1) For creating new report 2) For any screen field change at the movement i am looking this, by any change if i get all functional specifications i will be happy. the main reasin that i am