Release memory for nested top-level classes

Hello experts.
I have a top-level class which consists of several static methods. Inside such a method I create several new instances of a nested top-level class inside my original class. Later I want to release one of these instances i.e. destroy instance and free memory. How can I do that?
Thanks.

sure, but I do not see any references to this nested top-level class. With "Releasing" I mean something like directly assigning a NULL value to the nested top-level clas in order to enable GC.
But as I said there are no references and while monitoring the memory I see that the GC does not collect some memory. (I know that GC is not reliable, but after ten attempts of this scenario the memory allocation is equal the whole time).
I guess the GC does not work with classes, but the classloader. But how can I control releasing memory in this scenario?
Any further hints?

Similar Messages

  • What makes a class a "top-level" class?

    1.
    2.    public static int getThis() {
    3.      int x = 4;
    4.      int y = 5 * x;
    5.      return y;
    6.    }
    7.  }
    8.
    9.  public class NetGro extends ToNet {
    10.    public static void main(String args[]) {
    11.      int z = getThis();
    12.      System.out.println("Z = " + z);
    13.    }
    14.  }At line 1 of this program, ToNet "can only be declared as public or the default of no modifier" (not private or protected) because it's a "top-level class." What makes ToNet a "top-level class?"

    A class or interface is 'Top-Level' if it is not nested inside another class or interface.
    Otherwise the class would not be visible... Private and Protected for classes and interface only make sense within another class or interface as inner classes or interfaces.
    Hope that helps...

  • Declaring top level classes instead of subclasses

    I seem to have misunderstood something very basic.
    It's always better, where possible, to declare the top-level class instead of the sub-class, right?
    Ok, then why do I have the following problem?
    I declare, from the JavaMail API the following:
    Message theMessage = new MimeMessage(session);instead of declaring directly the subclass like this:
    MimeMessage theMessage = new MimeMessage(session);but when I use a method which is only found in the MimeMessage class I get a compile error.
    [javac] 189.           theMessage.setSubject(subject, "iso8859_1");
    [javac] <-------------------------------->
    [javac] *** Error: No match was found for method "setSubject(java.lang.String, java.lang.String)".
    Have I really misunderstood something so basic?? Surely the compiler knows that theMessage is an instance of MimeMessage??
    Any clear explanation to explain why I get this compile error would be gratefully received. I have been faithfully declaring top-level classes instead of subclasses in my code, but if the compiler doesn't let you do so, then what's the point?

    Ok, my confusion was started by an article on the
    Collection classes which stated that:
    Map theMap = new HashMap(); was better
    programming practice.
    Yep.
    But the Map class is an Interface, right? - Whereas
    Message is a normal class with subclass MimeMessage.
    I think that's where my confusion started.Well, this isn't really a class vs. interface difference. It goes to which class (or interface) is the "highest" (closest to Object) and still has all the public interface you need.
    There are cases where you'll declare a variable to be of a base class type like Message.
    You just need to get into the habit of separating the left side of the = from the right side. On the left, you put the bare minimum that completely meets your needs. You say, "I need a List" or "I need a Map" or "I need a SortedMap" (a subinterface of Map) or "I need a Message" or "I need a MimeMesage".
    Then, on the RHS =, you decide which particular class best implements the public interface that you said you need (by declaring it on the LHS). "For my Map, I'll use a HashMap." "For my Message, I'll use a MimeMessage." "For my MimeMessage, I'll use a MimeMessage".

  • What is top level class declaration in java?

    What is top level class declaration in java?

    The declaration of a class that's not nested inside any other class.

  • Top level class ?

    hi,
    i am preparing the sun certified java progammer, there's some questions involving "top level class", i don't understand what is a top level class ? can anyone give me some information about it ? is it a class at the top of a package hierarchie like class Object ????
    thanks for your help

    hi,
    i am preparing the sun certified java progammer,
    there's some questions involving "top level class", i
    don't understand what is a top level class ? can
    anyone give me some information about it ? is it a
    class at the top of a package hierarchie like class
    Object ????No. See
    http://java.sun.com/docs/books/jls/second_edition/html/packages.doc.html#26783
    Jim S.

  • Issue with having to declare fixed width for my top level floated LI in horizontal menu

    Hi and thanks for taking a look at my problem:
    I am having trouble getting my sub menus to display correctly in IE.
    Originally i didn't declare a fixed width for my top level li and it displayed perfectly in all browsers except IE.
    If i don't declare a fixed width for my floated floated elements, IE treates the top level li as the same width as the ul they contain (which I don't want). So I declared a width for the ul.MenuBarHorizontal li to be 80px, which is close to the minimum width that i want to use for the top level list items. However, in actual fact, the top level list items all have individually declared widths in the classes they are assigned.
    How can i re-write the html or CSS so that the browser, mainly IE, reads the correct widths for the top level ist li??
    Here is a link to the page with the problem
    Thanks in advance if anyone can help me out.

    Hi Beth,
    thanks so much for your repsonse.
    I will take your notes and advice and see if i can apply it to the actual page i was referring to. It seems you were now looking at a completely different page with a different (albeit spry) horizontal menu.
    Again, i truly appreciate your time and advice.
    Thanks!

  • Agents configuration for the top level Organization

    I was experimenting with this feature and was wondering if it works. I have an IIS 6.0 policy agent installed and it is working correctly. I added a new agent for the top level org and set the name, password to the amldapuser password, and agentRootURL key value. I then edited the AMAgent.properties file of the IIS 6.0 policy agent and changed the com.sun.am.policy.am.username to the one I created. Upon restart the policy agent could not authenticate. I then set the am.password the clear text password and got the same result. Has anyone got this to work?

    Hi ,
    I've Been Following this forum for quite a long time,This has been a good resource for the people working on Identiry Management. A problem has been hindering me from completing the authentication part in my project.
    I've configured the Policy Agent in AMAgent.property file as URL_POLICY mode,which
    would redirect the user to the User Home Page mentioned in the
    registration page of Identity server. what other configurations need to be changed to make this work.
    Thanx,
    Daniel Prem Kumar B.S.
    Hyderabad , India.

  • How to create top level classes

    what is the meaning of top level classes. and how to create toplevel classes.

    http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000188.html

  • SetCursor use for multiple top level windows (JFrame)

    Hello,
    I have an application with many top level windows, most of which are running under a single
    thread. I'm trying to implement a class to toggle the cursor (normal<->busy) for any window
    that is present in the application.
    I can't seem to get the cursor to change for any window other than the main window. I'm providing
    below the class that's used to register the windows and set the cursors.
    What am I missing?
    import java.awt.Cursor;
    import java.util.ArrayList;
    import javax.swing.JComponent;
    import javax.swing.RootPaneContainer;
    public class AppWindows {
        ArrayList<WinInfo> windows;
        /** Creates a new instance of AppWindows */
        public AppWindows() {
            windows = new ArrayList<WinInfo>();
        public void add(JComponent window, String title) {
            WinInfo win = new WinInfo(window, title);
            windows.add(win);
        public void delete(JComponent window) {
            windows.remove(window);
        public void deleteAll() {
            windows.clear();
        public void setBusyStatus(boolean busy) {
            for(int i=0; i<windows.size(); i++) {
                JComponent j = windows.get(i).getWindow();
                RootPaneContainer root = (RootPaneContainer)j.getTopLevelAncestor();
                if(busy == true) {
                    root.getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    root.getGlassPane().setVisible(true);
                else {
                    root.getGlassPane().setCursor(Cursor.getDefaultCursor());
                    root.getGlassPane().setVisible(false);
    class WinInfo {
        private JComponent win;
        private String title;
        public WinInfo(JComponent win, String title) {
            this.win = win;
            this.title = title;
        public JComponent getWindow() {
            return win;
    }Bill

    I would very much like to know how to avoid this also!!!

  • How do I use CreateBookmarksFromGroupTree and NOT guid in the name for my top level?

    Post Author: Barbdcg
    CA Forum: Deployment
    I have a report that I have created that uses uses groups and I wanted export a PDF using the CreateBookmarksFromGroupTree option. While that works, I get an ugly top level bookmark name that starts with the name of my report, then followed by a GUID;
    Report {49E72CC5-7FFD-44F8-831B-EA8F543F7D82}.rpt
    So, how do I Put in a name of my own choosing as the top-level bookmark or at least get rid of the guid?
    Any help or suggestions would be appricated.
    Thanks,
    Barb

    Post Author: Barbdcg
    CA Forum: Deployment
    Still no answer??? I can not figure this one out!!  HELP!!!

  • How do I use CreateBookmarksFromGroupTree and NOT get a "temp_" for my top level?

    I have a report that I have created that uses uses groups and I wanted export a PDF using the CreateBookmarksFromGroupTree option. While that works, I get an ugly top level bookmark name that starts with "temp_" then followed by two GUIDs "temp_13fef8e3-30ec-4bc5-ba77-b55d23c95e8f {87823BCB-7789-407C-8A7F-5096BE07A83E}".
    So, how do I:
    1) Get rid of this top level so it matches the Crystal Viewer (which has multiple top level bookmarks)
    2) Put in a name of my own choosing as the top-level bookmark.
    <!break>
    Any help or suggestions would be appricated.
    Thanks,
    Jim

    I would very much like to know how to avoid this also!!!

  • Protected top-level classes - what do you think about?

    See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6310261

    What is subpackage? Is it like below?
    it.is.my.package.*; //the package
    it.is.my.package.subpackage.*; //the subpackage
    Exactly.
    If it is, well, I like the idea. It would improve the
    java. I�ve already had some idea like that. I
    thought: "Why don�t exist relations between packages
    in Java?".Sun claims there is no relationship, but assertions you can enable or disable for the package and all subpackages with one command.
    If you like this idea, please vote for this RFE.

  • Opening a Remote Panel of the Top Level vi for an executable

    Hello Everyone
    I was wondering how you would open up a remote panel for the top-level vi in an executable?
    I have created a LabVIEW application and have tested opening the remote panel when it is running in the full labview development suite - this all works fine. I simply go operate>connect to remote panel and enter the server address, the port (8000) and the vi name using the path "My Project.lvproh/My Computer/main.vi" format.
    However, if I then build this application into an executable I do not seem to be able to open a remote panel - it might be that I am just entering the VI name incorrectly.
    with VI name = "main.vi"  or with VI name = "C:\builds\main.exe\main.vi" and the exe. running I get the error:
    Connecting to remote panel server...
    Requested VI is not loaded into memory on the server computer
    However I am not sure how else I would enter it.
    The main.ini has the following configuration:
    server.app.propertiesEnabled=True
    server.ole.enabled=True
    server.tcp.acl="0800000008000000"
    server.tcp.enabled=True
    server.tcp.paranoid=True
    server.tcp.port=6363
    server.tcp.serviceName=""
    server.vi.access=""
    server.vi.callsEnabled=True
    server.vi.propertiesEnabled=True
    WebServer.Enabled=True
    WebServer.TcpAccess="c+*"
    WebServer.ViAccess="+*"
    DebugServerEnabled=True
    DebugServerWaitOnLaunch=False
    Both machines have LabVIEW 2011 Profesional Development System SP1 on so I do not think it is a limited remote access licence issue.
    Any suggestions as to where I am going wrong would be much appreciated.
    Cheers
    John
    Solved!
    Go to Solution.

    It appears that you can infact use remote panels within an executable.
    The problem I had was that I had left the web server port for the remote panels the same as the LabVIEW development environment. That meant that the main LabVIEW web server was getting in the way of the web server that was associated with my built application.
    With the application's web server on a different port and the VI in memory (and the file in a library/directory external to the exe if it is not the top level VI), you just need to specify the VI name such as main.vi .
    Solved!

  • How to release top-level VI (only) source code?

    Hello,
    I am developing an addon to an application I already have. The application is large (over 1,500 VI's) and the VIs are set up to compile with mostly default settings (there's a top-level VI, a few with Front Panel visible, most of them are not visible).
    The customer wants the source code to the work I'm going to do, and it's going to use many existing sub-VI's. The addon itself will be a sub-VI (I have a Main.vi that basically opens 'screens', and this is a new screen). The existing sub-VI's basically do the data collection and processing, and the new code will do some additional processing and have a nice GUI to the existing code. The customer wants the source so they can make modifications as needed.
    Is there any easy way to provide just the source for the top-level VI? Basically, I want to give them M.vi, where M.vi calls n.vi, o.vi... etc, but o-z.vi need to remain closed-source. Also, M.vi is called by Main.vi, which opens screens A-M.vi
    One option is do copy the entire application, then open every sub-VI and save it without Source Code. But with so many files, this seems like a bad idea. I also then have to maintain two applications.
    Any good ideas out there? It seems so easy in other languages (use object files) that it seems like there should be a solution here I'm not seeing.... Thanks!
    Message Edited by rnelsonee on 06-02-2010 08:28 AM
    Message Edited by rnelsonee on 06-02-2010 08:31 AM
    Solved!
    Go to Solution.

    Dont know if this is the best solution for you, but you can create a "virtual folder" in the LabVIEW project with all the sub-VIs that you want to keep closed-source. Then create Source Distribution build specifications in the project and remove the block diagrams assign passwords to all VIs in the virtual folder. See attached pics.
    Attachments:
    Project.JPG ‏23 KB
    SrcDist.JPG ‏62 KB

  • Posting from Top Level WBSE to AUC

    Hi Friends,
    I am facing problem in doing settlement from Top level WBSE to AUC. I feel I have done the required settings. I am not able to generate settlement rule for the top level WBSE. Please help me out. I would appreciate some screen-shot help from anyone.
    regards
    Pratap.V

    Hi,
    Captain Caveman: I want the settlement from the top level WBSE to AUC get generated automatically. My Top level WBSE has an Investment profile. AUC is created automatically only. Since the settlement rule did not get generated automatically, I tried to set the rule manually. Still the system is not allowing me to do. Top level WBSE is acc assigned.
    Steve: In my settlement profile, I have given the default object type as FXA.
    Subhrajyoti: I have checked the asset class. The asset is not blocked. Also the status of AuCi s set right.
    Thanks guys for your replies. I will do the whole process again.
    I will check and let you know the results today itself.
    thanks
    Pratap.V

Maybe you are looking for