`
jacky-zhang
  • 浏览: 315893 次
  • 性别: 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 ...

    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,...

    汽车新能源与节能技术应用研究 (4).pdf

    In addition, the integration of renewable energy sources, such as solar and wind power, into charging networks can further reduce the carbon footprint of new energy vehicles. Battery recycling and ...

    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 ...

    orCAD capture Footprint 封装路径设置

    - 在预览封装时出现错误提示:“ERROR(ORCAP-1733) Allegro footprint was not found in the search path”。 - 即使设置了 `psmpath` 环境变量,该变量仅对 Allegro PCB Editor 生效,对 orCAD Capture 无效。 - 在...

    USB_2.0_footprint.rar_footprint_usb footprint_usb 封装_usb封装

    USB 2.0 Footprint是电子设计领域中的一个重要概念,主要涉及硬件工程师在设计电路板(PCB)时,为USB接口创建合适的物理布局。这个压缩包文件包含了关于USB 2.0接口封装的详细信息,对理解USB接口在PCB布局中的应用...

    General MIDI Lite Version 1.0

    Each instrument is carefully chosen to cover a wide range of musical styles while minimizing the overall memory footprint. - **Channels**: GML specifies a total of 8 channels instead of the 16 found...

    The Brand Footprint品牌印记.doc

    【品牌印记】是市场营销中的一种重要工具,由广告公司麦肯提出,用于定义和管理品牌的本质,确保品牌在扩展和延伸过程中保持其核心价值。品牌印记不仅关注消费者对品牌的感知,也考虑品牌所有者对品牌的未来发展愿景...

    Footprint_Expert_2022-02_Pro,封装制作神器

    《Footprint Expert 2022-02 Pro:封装制作的艺术与技术》 在电子设计领域,PCB(Printed Circuit Board)封装是至关重要的一步,它涉及到电子元器件在电路板上的精确布局和互连。而"Footprint Expert 2022-02 Pro...

    Footprint Expert Pro 元器件PCB封装建库神器,软件

    【标题】:“Footprint Expert Pro 元器件PCB封装建库神器,软件” 【描述】:Footprint Expert Pro是一款专为电子工程师设计的PCB封装建库工具,它旨在简化和加速元器件封装的创建过程,是工程师进行硬件设计时不...

    my footprint.zip

    本压缩包"my footprint.zip"包含了几个重要的Altium Designer封装库文件,这些文件是用于创建和管理电子元器件的物理形状和连接方式,对于PCB设计至关重要。 1. **软排线座子.LIB**:软排线座子,也称为柔性扁平线...

    Footprint_Expert 2023.08_Pro.Patched-原生支持Allegro 22.1.zip

    《Footprint Expert 2023.08 Pro——打造高效电路板设计的新里程碑》 在电子设计领域,电路板设计软件是工程师们的得力工具,而Footprint Expert 2023.08 Pro正是这样一款专为高级设计师量身定制的专业软件。这款...

    一个开源的检测程序运行算法问题的耗时和内存占用的小工具,An open source gadget that detects t

    一个开源的检测程序运行算法问题的耗时和内存占用的小工具,An open source gadget that detects the time and memory footprint of running algorithm problems

    Footprint_Expert_2022-04_Pro.zip

    《Footprint Expert 2022-04 Pro——专业PCB设计的足迹专家》 在电子设计领域,PCB(Printed Circuit Board)设计是至关重要的一步,它关乎到设备的性能、可靠性和制造成本。Footprint Expert 2022-04 Pro是一款专...

Global site tag (gtag.js) - Google Analytics