Are any benifits of static declarations regarding memory Usage

Hi,
I am new to java programming and I am currently working on Code Optimization to improve application performance and reduce run time memory usage. So, please I need tips on performance improvement and memory consumption.
Is static method declaration helpful to reduce memory usage and to improve performance?
Please, reply me?
Thanks and Regards
Dagadu Akambe

BigDaddyLoveHandles wrote:
georgemc wrote:
Write good, straightforward object-oriented code that doesn't use tricks, and don't try to optimise it yourelf. SeriouslyThat's exactly what Brian Goetz expressed in the article I linked to in reply #8.
I've always wondered about the newbie obsession with optimization.
This is not directed to the OP especially, but I've seen it happen many times: newbie is still writing inelegant, if not tortured code, and they get this bee in their bonnet that they have to optimize it, so they pound the code until it is beyond incomprehensible. Then they time it and it runs more slowly!Perhaps they're crafting O(n^3) sort routines, and not knowing about things like appropriate data structures and algorithms, big-O measurement, etc. the only conclusion they're able to draw is that their code is slow because they're creating so many objects, and declaring variables inside of loops, etc.

Similar Messages

  • High Virtual memory usage when using Pages 2.0.2

    Hey there,
    I was just wondering whether there had been any other reports of unusually high memory usage when using Pages 2.0.2, specifically Virtual memory. I am running iWork 06 on the Mac listed below and Pages has been running really slowly recently. I checked the Activity Monitor and Pages is using hardly any Physical memory but loads of Virtual memory (so much so that the Page outs are almost as high as the Page ins (roughly 51500 page ins / 51000 page outs).
    Any known problems, solutions or comments for this problem? Thanks in advance

    I don't know if this is specifically what you're seeing, but all Cocoa applications, such as Pages, have an effectively infinite Undo. If you have any document that you've been working on for a long time without closing, that could be responsible for a large amount of memory usage.
    While it's good practice to save on a regular basis, if you're making large amounts of changes it's also a good idea to close and reopen your document every once in awhile, simply to clear the undo. I've heard of some people seeing sluggish behavior after working on a document for several days, which cleared up when the document was closed and reopened.
    Titanium PowerBook   Mac OS X (10.4.8)  

  • Memory usage of ApplyLogOnInfo and TestConnectivity

    Hi,
    Our application is coded in C++ (VS 2005)  and we access the Crystal Report 2008 API using .NET (CR 2008 SP1). In the application, when a report needs to be printed, it will
            Load the report
            Login to the database
            Set the parameters
            Print the report
            Close the report
            Perform garbage collection
    One of our customers has a very large report (.rpt > 2 M), which has many subreports and each subreport accesses a number tables.While observing the memory usage from Task Manager on win 2008, I can see loading the report self eats up about 100 M, then Login to the database will consume another 400 M, when the Report is closed, the memoary drops back a little bit and stays at around 500 M. Re-run the same report again, the memory will go up by another 200 M mainly during the login step. Then it stays at around 700 M for subsequent printing requests.
    For reports which are small (< 100 k) and do not have a lot of subreports, the memory usage will be around 150 M. I am wondering why the login step will use some much memory and they do not get freed up when the report is close for the second report request.
    The following is the code for the login step:
    void CRptWriterIntf::SetDBConnectionInfo()
         m_TableLogOnInfo = gcnew TableLogOnInfo;
         m_TableLogOnInfo->ConnectionInfo->DatabaseName = gcnew System::String(m_serverName.getBuffer());
         m_TableLogOnInfo->ConnectionInfo->ServerName = gcnew System::String(m_dbName.getBuffer());
         m_TableLogOnInfo->ConnectionInfo->UserID = gcnew System::String(m_dbUser.getBuffer());
         m_TableLogOnInfo->ConnectionInfo->Password = gcnew System::String(m_dbPass.getBuffer());
    void CRptWriterIntf::ReportLogon(ReportDocument^ reportDocument)
         SetReportLogonInfo(reportDocument);
         for (int i=0; i < reportDocument->Subreports->Count; i++)
                 ReportDocument^ subReport = reportDocument->Subreports<i>;
                 SetReportLogonInfo(subReport);
    void CRptWriterIntf::
    SetReportLogonInfo( ReportDocument^ reportDocument)
        for (int i=0; i < reportDocument->Database->Tables->Count; i++)
            Table^ table = reportDocument->Database->Tables<i>;
            table->ApplyLogOnInfo(m_TableLogOnInfo);
            if (!table->TestConnectivity())
                LOG_ERROR();
                CleanEngine(reportDocument);
                throw e;
    Thanks
    Kin H Chan

    Thank you for the suggestion.
    I updated my Crystal Report 2008 to SP4, but that does not seem to make any difference in term of the memory usage.
    I do not find any function to close the DB connection from the Crystal Report 2008 .NET API Reference. Am I missing something?
    The Depose method is a protected method which I cannot access directly from the ReportDocument object. Instead, it will be called in the destructor of ReportDocument according to the documentation.
    In my codes, after the report is generated, I always perform:
    Close the report by:
         reportDocument->Close()
    and
    Perform garbage collection
         System::GC::Collect();
    If I skip either one of the two calls below, the report will fail to access the db from the report
         table->ApplyLogOnInfo(m_TableLogOnInfo);
         if (!table->TestConnectivity())
    That is the reason that I have them there. Are there alternative to this approach?
    By the way, how can I attach file (e.g. screen shots, sample codes, sample reports) to my question?
    Thanks
    Kin H Chan

  • Occasional video freeze, related to memory usage?

    Hi all,
    I've been experiencing problems playing divx and flv (firefox) videos.
    The image freezes for a second, then keeps playing, then freezes... again and again.
    I have the same problem with VLC, MPlayer OS X, I have tried uninstalling Perian, or Flip4mac...
    Computer updates are ok.
    It looks like a memory usage issue to me but I am not sure.
    Any idea?

    Welcome to Apple Discussions!
    One thing you could try is to go to System Preferences>QuickTime>Streaming and set the bar for a longer delay. I get this a lot with dial up, and I think it's because the download speed is slow. It downloads a little, plays a little, downloads a bit more, plays a bit more...and so on. With really fast internet, I think it downloads faster than it plays, so you don't get this.
    Good luck!

  • Resource monitoring - memory usage

    I typically use the system monitor on our SLES11 SP2 server (OES11 SP1). The server has 48 GB of memory as our backup software, Arkeia, loves memory. When monitoring resource usage during an Arkeia backup job, I notice that my memory usage remains around 9.4 GB. However, if I look at the process table, my Arkeia job is using well over 16 GB alone.
    So the questions are : Why the difference? And is this a bug?
    The one thing that comes to mind is the resource monitor is only looking at OS memory usage and is not adding "user process" memory. Any thoughts on this? Chris.

    What exact tool(s) are you using to monitor Arkeia's memory usage, and the overall memory usage? Can we see their output please? I'd guess they're really looking at different things.

  • How to specify maximum memory usage for Java VM in Tomcat?

    Does any one know how to setup memory usage for Java VM, such as "-Xmx256m" parameter, in Tomcat?
    I'm using Tomcat 3.x in Apache web server on Sun Solaris platform. I already tried to add the following line into tomcat.properties, like:
    wrapper.bin.parameters=-Xmx512m
    However, it seems to me that this doesn't work. So, how about if my servlet will consume a large amount of memory that exceeds the default 64M memory boundary of Java VM?
    Any idea will be appreciated.
    Haohua

    With some help we found the fix. You have to set the -Xms and -Xmx at installation time when you install Tomcat 4.x as a service. Services do not read system variables. Go to the command prompt in windows, and in the directory where tomcat.exe resides, type "tomcat.exe /?". You will see jvm_options as part of the installation. Put the -Xms and -Xmx variables in the proper place during the install and it will work.
    If you can't uninstall and reinstall, you can apply this registry hack that dfortae sent to me on another thread.
    =-=-=-=-=-=
    You can change the parameters in the Windows registry. If your service name is "Apache Tomcat" The location is:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Apache Tomcat\Parameters
    Change the JVM Option Count value to the new value with the number of parameters it will now have. In my case, I added two parameters -Xms100m and -Xmx256m and it was 3 before so I bumped it to 5.
    Then I created two more String values. I called the first one I added 'JVM Option Number 4' and the second 'JVM Option Number 5'. Then I set the value inside each. The first one I set to '-Xms100m' and the second I set to '-Xmx256m'. Then I restarted Tomcat and observed when I did big processing the memory limit was now 256 MB, so it worked. Hope this helps!
    =-=-=-=-=
    I tried this and it worked. I did not want to have to go through the whole reinstallation process, so this was best for me.
    Thanks to all who helped on this.

  • PowerPoint Presentation Memory Usage

    I have created a number of swf files to demonstrate the use
    of a program, using Captiveate 2. There are about 5 or 6 of them,
    and each is no more than a min in length. They was created using
    full motion recording and the resultant flash files are no larger
    than 2 MB in size.
    I import these into PowerPoint 2003 as a shockwave flash
    object and they appear fine when the slides are presented. However,
    the computer quickly grinds to a halt, and looking at task manager
    on another monitor whilst the flash files are playing, I can see
    PowerPoint's memory usage ramp up at the rate of about 10 MB/sec.
    Moving onto the next slide does not clear the previous slides
    memory usage, hence windows quickly runs out of virtual memory.
    I do not see this behaviour when I import alternative flash
    files into PowerPoint. I have tried this with/without the _skin.swf
    file but the resutls are the same. Has anyone seen this behaviour
    before? I have also tried this on a number of computers, and the
    same issues are seen.

    Hi High Tower
    I'm surprised you aren't also seeing what we call the RSOD
    (Red Screen Of Death). This happens when you have used Captivate to
    record longer full motion recordings. What happens is that each
    full motion clip is loaded into memory until all memory (virtual
    and otherwise) becomes totally depleted. The screens begin showing
    red spots and quickly move from that to the full screen being red.
    This really isn't an issue with Captivate. Moreover, it's an
    issue with the way the Flash player handles the full motion clips.
    Sorry, but the only way I'm aware of to work around it is to
    structure your projects differently. Avoid using full motion if you
    can and use slide based recording whenever possible.
    Hopefully this was helpful... Rick

  • 99% memory usage all the time (MSI GX70 Destroyer)

    Hi
    My MSI Gx70 destroyer (6 months old) is running slow even when I'm not using any programs.
    I noticed my Memory Usage is allways at 97-99% but I can't find the cause.
    The "Non paged pool" seems to be taking up 6,4GB
    I tried to google the problem but I can't find it (I don't know much about computers)
    MSI GX70 3CC Destroyer
    AMD A10-5750M APU with Radeon(tm) HD Graphics, 2500 MHz
    8GB RAM (7,19GB available)
    64bit x64 processor
    Windows 8.1
    I've added a screenshot of my processes (It's in Dutch but you get the point)
    Any help would be very much appreciated

    Update your LAN driver to the latest available one on MSI website.
    http://www.msi.com/faq/nb-1032.html

  • Why inner classes cannot have static declarations ?

    Hi Friends,
    When i tried to make static declarations on a inner class which is non static, i am getting compilation error saying "inner classes cannot have static declarations". I want to know reason behind this implementation.
    Code which i have tried:
    public class TestOuter
    class TestInner{
    static int i =10;
    public static boolean validate(int a){
    if(a==0)
    System.out.println("Invalid data");
    return false;
    return true;
    public static void main(String a[]){
    boolean result = new TestOuter.TestInner.validate(0);
    System.out.println("Result="+result);
    Thanks,
    Shiju V.

    so I think if the
    outer class is not static , then Inner class can't be
    static as well. This is incorrect. An enclosed class can be indeed static while the outer is not, and vice versa.
    The difference between static/non static in regards to enclosed classes is that the static ones are 'top-level' and cannot access the members of the enclosing class.
    The effect of making an enclosed class static means there is only one instance of any variables, no matter how many instances of the outer class are created. In this situation how could the static inner class know which variables to access of its non static outer class. Of course the answer is that it could not know, and thus an static inner class cannot access instance variables of its enclosing class.
    Now, regarding non-static inner classes, and trying to give a valid answer to the original post:
    As with instance methods and variables, a non-static inner class is associated with an instance of its enclosing class and has direct access to that object's instance variables and methods.
    TestOuter outer = new TestOuter();
    TestOuter.TestInner inner = outer.new TestInner();Because an inner class is associated with an instance (inner class implicitly keeps a reference to the object of the enclosing class that created it), it cannot define any static members itself. Static members cannot access the this pointer.
    So, in an ordinary (non-static) inner class, the link to the outer class object is achieved with a special this reference. A static inner class does not have that special this reference, nor would a static method/variable of an ordinary (non-static) inner class.

  • Having a problem with Excessive "modified" memory usage in Win7 x64, upwards of 3.6GB, any suggestions?

    I have 6GB of ram, a fresh install of Windows 7 x64, and the screenshot shows what happens after leaving my PC on for a couple days. (3782+MB being used by modified memory ATM).
    http://wow.deconstruct.me/images/ExcessiveMemory.jpg
    Any ideas on this?
    Edit:
    Added this after first round of suggestions
    http://wow.deconstruct.me/images/NotSoExcessiveMemory.jpg
    This is uptime of around 2 hours.
    The first image is of uptime of around 3-5 days.

    Matthew,
    The only reason why these pages are kept on the modified list indefinitely is because the system doesn't have any available pagefile space left. If you increase the size of the pagefile the system will write most of these pages to disk and then move them from the modified list to the standby list. Standby pages are considered part of "available memory", because they can be reused for some other purpose if necessary.
    Whether this would "fix" the problem or not depends on what the actual problem is. If it's an unbound memory leak then increasing the size of the pagefile will simply allow the system to run longer before it eventually hits the maximum pagefile size limit, or runs out of disk space. On the other hand, if it's a case of some application allocating a lot of memory and not using it for a long time, then increasing the pagefile might be a perfectly valid solution.
    Allowing the system to manage the size of the pagefile actually works well in most cases. Pagefile fragmentation (at the filesystem level) can only occur when the initially chosen size is not large enough and the system has to extend it at run time. For win7 we have telemetry data that shows that even for systems with 1 GB of RAM, less than 0.1% of all boot sessions end up having to extend the pagefile, and this number is even lower for larger amounts of RAM. If you think you are in that 0.1% and your pagefile might be getting fragmented, you can manually increase its minimum size such that the total system commit charge stays below 80% even if you run all your apps at once (80% is the threshold at which the pagefile is automatically extended). This will make sure the pagefile is created once and then stays at the same size forever, so it can't fragment. The maximum size can either be set to the same value as the minimum, or you can make it larger so that the system is more resilient to memory leaks or unexpectedly high loads.
    By the way, Windows doesn't use pagefiles as "extra memory", it uses them as a backing store for private pages, just like regular files are used as a backing store for EXEs/DLLs and memory mapped files. So if the system really has more than enough RAM (like in your second screenshot, where you have 3.6 GB of free pages) you shouldn't see any reads from the pagefile. You can verify this by going to the Disk tab in the resource monitor and looking for any disk IO from pagefile.sys. On smaller systems that don't have an excess of free pages you may see periodic reads from the pagefile, and this is expected because the total amount of data referenced by the OS/drivers/processes is larger than the total RAM. Forcefully keeping all pagefile-backed pages in memory (which is what disabling the pagefile does) would simply mean some other pages (memory mapped files, DLL code or data etc) would have to be paged out.
    Regarding further troubleshooting steps: If the system runs fine with a larger pagefile (commit charge stabilizes well below 80%, and you no longer see gigabytes of modified pages accumulating in memory) then you don't really need to do anything. If the problem persists, you can check for any processes with an abnormally high commit charge, and also check kernel memory usage in task manager. If it's a kernel leak you can usually narrow it down to a particular driver using poolmon.exe or kernel debugger.

  • Why we go for SAP ?what are the benifits to implement SAP inanyorganizat?

    Hi,
    Why we go for SAP ?what are the benifits to implement SAP in  any organization?
    Early reply is highely appruciable.
    Regards,
    Chow.

    Hi
    check following link for ur doubts
    http://www.sap.com/solutions/business-suite/erp/businessbenefits/index.epx
    Some key points to switch to SAP is like
    Focus on Business Processes
    Elimination of Redundant Data (Common & Consistent Data)
    Easier Corporate Consolidation
    Better Managerial Control
    Elimination of Interfaces
    Faster reaction to changing structures
    Organization/Customers/Competitors
    Integration is the Key
    Integration of all business modules
    Major reduction in time required for accounts finalization
    Easier Corporate Consolidation
    Cost control – Batch wise / Cost centre wise
    Centralised Inventory planning and control
    Reduction in Inventory carrying Costs
    Best Business practices across the organisation
    Elimination of redundant data
    Better Managerial control
    Data Integrity
    Enhanced Organisational flexibility
    Improvement in Personal productivity
    High Data availability
    Improved Order cycle time / accuracy / cost
    hope this is what ur looking for
    If not pls revert
    Vishal...

  • Reason for not allowing static declarations inside an inner class

    Is the reason for not allowing static declarations inside an inner class is due to the fact that it can never be accessed at a class level as the outer class has to create an instance of the inner class and any attributes/methods of the inner class has to be accessed through that.
    Typically, an instance (non-static) variable can never be accessed in a statement or expression inside a static context but the class variable can be accessed inside a non-static context. Given this, shouldnt the static declarations be allowed inside an inner class?
    Correct me if my understanding is wrong.
    Thanks

    I still couldnt get it clearly. Why i cant i have a static value ( variable ) for all the instances of the inner class irrespective of its enclosing instances of it ( i.e outer class instances). Say in this example below,
    class Outer
    static int i = 0;
    public Inner inner = new Inner();
    class Inner // inner class ( non-static nested class )
    int j = 0;
    static final int k = 2; // compile time constants are allowed
    // ininner class
    public void m1()
    j++;
    System.out.println("j is " + j);
    i++
    System.out.println("i is " + i);
    public static void main(String[] arg)
    Outer outer1 = new Outer();
    outer1.inner.m1(); // j will be 1 & i will be 1
    Outer outer2 = new Outer();
    outer2.inner.m1() // j will be 1 again & i will be 2. But I would
    // want j to be 2. Why is this not allowed?
    Looks like something missing..

  • HT4623 Is there any way I can increase my memory without deleting stuff?

    Is there any way I can increase the memory on my iPhone 4 without deleting stuff?  eg by purchasing extra memory?

    No, there isn't. The amount of storage on an iPhone is fixed and cannot be increased. Your only options are to either delete stuff or purchase an iPhone with larger capacity.
    Regards.

  • Lightroom 5.7.1, Yosemite OS X - Synchronise Folder function doesn't work in Lr. Is there a compatibility issue? I can see the folders/images in Finder but when trying to synchronise folders in Lr it does not recognise that there are any images and theref

    Lightroom 5.7.1, Yosemite OS X - Synchronise Folder function doesn't work in Lr.
    Is there a compatibility issue? I can see the folders/images in Finder but when trying to synchronise folders in Lr it does not recognise that there are any images and therefore unable to import to catalogue. Anyone has any idea how to make it work. Thanks a lot.

    Hi Elba,
    Thank you very much for your reply. Not sure, however, that we are talking about the same problem.
    I am trying to perform the same function in Lr that I have been doing for many years in the past and has only been a problem in the last few days (possibly coinciding with upgrading to Yosemite, trying to find out whether that is the problem)
    I am not intending to sync any files with Creative Cloud but only trying to use 'Synchronize Folder' function in Lr. Normally, I would right click on a particular folder in Lr catalogue and click on that function to check that the Lr Catalogue is perfectly matching my drives where the original photos are actually stored.
    The problem that I only started to encounter is that I can see the files on the actual drives but they do not appear in my Lr Catalogue and they are completely invisible to Lr. I simply can not get Lr to recognise them and then import them to catalogue.
    If for example, I export images to Ps and then save and close them, they do appear on my drive but are invisible to Lr and I can't get them imported into the catalogue. Import to folder also not producing any results as they are still invisible to Lr.
    Completely baffled by it. Any idea what could be the reason?
    Kind regards,
    Nik

  • What is the command to check if there are any active calls before restarting the voice router?

    what is the command to check if there are any active calls before restarting the voice router? thanks

    Hi.
    I can suggest show call active voice or show voice call status or show sip-ua call brief in case of SIP TSP.
    HTH
    Regards.
    Carlo

Maybe you are looking for

  • My 4 Gen with IOS 4.2.1 cannot connect iTune and I want to upgrade IOS.

    My 4 Gen with IOS 4.2.1 cannot connect iTune and I want to upgrade IOS. Q1) What's wrong with my touch that iTunes cannot detect it? What should I do? Q2) Is there any method to upgrade IOS without connect to iTunes?

  • Premiere Pro CC crash after importing Media

    Hello, I'm using the trial version of Premiere Pro CC. I've used it for this week without any problem importing just pictures. Today I've imported videos and suddenly it started to crush after each importation. Now I can't import even pictures anymor

  • MacBook5.1 with 10.5.7 can't recongnize external HD

    What can I do I've tried every thing, HELP! -I format my HD to Mac OS Extended (Journaled) -I download the last version of airport utility 7.4.1 -I restart a lot of time - spend the entire day on the computer trying to solve this problem.... I am out

  • Daily HR Inteligence

    Hi, i need some help in Daily HR Inteligence, if i access the reports it is throwing the warning message as The Manager value '2962' is not valid for this Report. Manager has been set to empty. Please select valid value and re-run the report. where t

  • Table with Full / Delta Load information?

    Is there a table I can go to where I can see if a cube is a full load vs delta? Thanks, I will assign points! ~Nathaniel