`
jacky-zhang
  • 浏览: 310491 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

reduce the memory footprint of my J2ME application

    博客分类:
  • j2me
阅读更多
First consider how much effort you want to expend on this. Modern MIDP/CLDC devices have far more memory than the original specifications envisaged. If you must reduce memory size, bear in mind that all the following techniques will reduce the readability and manageability of your code. In no particular order...

    * Don't create separate classes to act as event listeners - use a class that already exists. For example, use your MIDlet's main class as the event listener for form events, rather than creating a separate class. Remember that even the most trivial, anonymous inner class requires 200 bytes of bytecode, plus some state information for each instance.
    * Where possible, use ordinary named classes, not inner classes. It is conventional in AWT programming to use inner classes to act as event listeners. The state information required to support an instance of an inner class can be surprisingly extensive, because of the way that inner classes are managed by the JVM.
    * Don't subclass the built-in classes unless you have to. For example, you could create a subclass of Form to serve as your applications main user interface, but you could also use an ordinary Form object, and drive it from the MIDlet's main class. Subclassing Form is more `OO', but imposes adds a few hundred bytes to the footprint. Every class you subclass has the same effect.
    * Don't subclass your own classes unless you have to. The flatter your class hierarchy, the few the classes; the fewer the classes, the smaller the bytecode.
    * Don't put your classes into packages. J2ME applications are self-contained, so there is no prospect for name clashes between applications. The packages names have to be stored in the bytecode, on every occasion that a class is defined or referenced. A better solution than de-packaging all your code is to use a software tool to do it. Bytecode obfuscators do this as part of their normal operation.
    * Remember that array initialisations translate into lots of repeated bytecode operations. So initializing an array of month names like this:

      String[] months = {"January", "February"...

    * generates a surprising amount of bytecode. If you have very large arrays of strings or numbers, it generates less bytecode to define it in a long, delimited String, and split it into individual values in a loop. This may seem mad, but it's true.
    * If you have to support multiple locales, plan on distributing different versions of the application for different locales, rather than supporting multiple locales in the same application. There's no point providing a load of French and Japanese text if the user wants to see only Italian.
    * If an application creates a Java instance, and knows that it is no longer required, it should re-use if with different data, or set it to null. Re-use is the preferred option, where this is practicable, but setting to null will help the garbage collector determine which objects are out of scope.
分享到:
评论

相关推荐

    libtiff4.1及jpeg zip静态库windows

    A subsequent update to the library to reduce the memory footprint for processing large TIFF files has been named version 4.1. The actual version when officially released may be different.

    Secure Java: For Web Application Development

    Provides a clear view of the growing footprint of web applications Explores the foundations of secure web application development and the risk management process Delves into tactical web application ...

    eMCP3+16+24G MT29TZZZ7D6JKKFB-107

    Our e.MMC-Based MCPs do more than meet the memory requirements of mid-tier phones, tablets, auto infotainment systems and smart watches. They save more than 40% space versus discrete memory—reducing ...

    The Brand Footprint品牌印记.doc

    The Brand Footprint品牌印记.doc

    Concurrency in Main-Memory Database Systems

    we determine the merit of traditional solutions in a main-memory context and suggest solutions which are ideally suited to the changed environment. In the first part of this thesis, the optimal ...

    STM8A Firmware Library and Examples

    Memory footprint of peripheral drivers Examples Document tabsheets description: "Modules" : Lists the different modules that compose this Library. "Data Structures": Lists the variables, defines,...

    Programming Wireless Devices with the Java™ 2 Platform, Micro Edition, Second Edition

    The result is a highly portable, small-footprint application development environment that brings the unique capabilities of Java technology, including platform independence and enhanced security, to ...

    advanced_RArray.pdf

    On embedded systems, understanding arrays is critical to getting the best performance and smallest memory footprint out of applications, and hence to improving the user experience. RArray and its ...

    Embedded.Software.Development.The.Open-Source.Approach.14665939

    Analyzes the main components of the FreeRTOS Application Programming Interface (API), detailing the implementation of key operating system concepts Discusses advanced topics such as formal ...

    JAVA-Based Agent Platform Evaluation

    fulfill, like FIPA interoperability, small memory footprint, cost, and security. For selected agent platforms – JADE, FIPA-OS, ZEUS and JACK – we present the results of benchmarking aimed at the ...

    Prentice Hall - Java Performance

    Tuning the Java HotSpot VM for startup, memory footprint, response time, and latency Determining when Java applications require rework to meet performance goals Systematically profiling and tuning ...

    Securing PHP Web Applications.pdf

    Reduce the Server’s Footprint 177 Secure the Web Root 179 Securing SQL Server 187 Install or Upgrade to the Latest Version 187 Secure Microsoft SQL Server 200 Wrapping It Up 205 Chapter 13 Securing ...

    Machine Learners Archaeology of a Data Practice pdf

    His archaeology of the operational formation of machine learning does not unearth the footprint of a strategic monolith but reveals the local tributaries of force that feed into the generalization ...

    Java_Performance

    Ø Tuning the Java HotSpot VM for startup, memory footprint, response time, and latency Ø Determining when Java applications require rework to meet performance goals Ø Systematically profiling and ...

    Java Performance

    Tuning the Java HotSpot VM for startup, memory footprint, response time, and latency Determining when Java applications require rework to meet performance goals Systematically profiling and tuning ...

    aes 加密代码

    into this "container" area and reduce the size of this "container" as necessary. If larger extensions are added or the "container" area is filled entirely, then reading and re-writing the entire ...

    Programming Microsoft Windows CE .NET

    Windows programmers interested in writing or porting an existing Windows application, and even developers of managed code can use the information in this book to make their tasks easier. <br>The ...

    Sybex.Mastering.VMware.vSphere.4.Aug.2009.pdf

    Using step–by–step instruction backed by real–world scenarios, this book takes you under the hood of this powerful VMware suite, clearly explaining all of the components and how you can get the ...

    uC-FS-4.08.00.zip

    Scalable: The memory footprint of µC/FS can be adjusted at compile-time based on the features you need and the desired level of run-time argument checking. For applications with limited RAM, features...

    微软内部资料-SQL性能优化3

    An application should maintain the consistency of a database. For example, if you defer constraint checking, it is your responsibility to ensure that the database is consistent. Isolation Concurrent ...

Global site tag (gtag.js) - Google Analytics