56660

Does a debug release of an Android app have a higher chance at being killed?

Question:

The Android docs say:

<blockquote>

Finally, if the application is being signed in release mode, you must align the .apk with the zipalign tool. Aligning the final .apk decreases memory usage when the application is -running on a device.

</blockquote>

Does this mean memory usage as in "hard drive space" or memory usage as in "ram" while the process is running?

see: <a href="http://developer.android.com/sdk/installing/studio-build.html#detailed-build" rel="nofollow">http://developer.android.com/sdk/installing/studio-build.html#detailed-build</a>

Answer1:

It can help to reduce the RAM footprint.

Uncompressed assets can be memory-mapped directly from the APK file, which allows them to occupy "clean" pages rather than "dirty" pages, and have each page loaded only when needed. The advantage of "clean" pages is that they can be evicted and reloaded from the source, whereas "dirty" pages cannot. (For more details, see <a href="https://stackoverflow.com/questions/2298208/how-do-i-discover-memory-usage-of-my-application-in-android" rel="nofollow">this answer</a>.)

Compressed assets must be uncompressed before they are used, so they are generally uncompressed fully when first accessed, and occupy "dirty" pages.

The alignment is useful for certain types of files that are expected to be aligned in memory. During early Android development, PNG files were mapped directly, but the PNG library was reading data 32 bits at a time. The emulator was configured to signal a bus error on unaligned 32-bit accesses, so the app crashed. To avoid this issue, zipalign was created to adjust the archive to ensure that the file contents have 32-bit alignment, and the asset manager was updated to only use direct mapping for aligned files.

zipalign has no real impact on disk space. It makes the file 0-3 bytes larger for each uncompressed asset in the APK.

Coming back to the question in the subject: depending on the app's assets and how they're used, running zipalign might reduce the app's chance of being killed. However, there's no reason you can't run zipalign on a debug release. It just adds a bit of padding to the zip file structure.

Recommend

  • What types of audio are supported by Cloud Speech API?
  • How to silence EllipticCurvePublicNumbers.encode_point CryptographyDeprecationWarning when using Par
  • Adjust cell width in grouped UITableView
  • gulp build for semantic ui very slow
  • Is there such a thing as static jar linking in java?
  • How to improve memory footprint for iPad apps
  • How to resize UIViewControllerWrapperView
  • auto layout leading or trainling -16
  • AVAudioPlayer - Why is there a gap between loops (uncompressed audio)
  • How can I spawn a long running process in a Perl CGI script?
  • What are the use cases of dlopen vs standard dynamic linking?
  • Rails 4.0.0 jQuery Mobile button icons not showing in production
  • Simple test app deploys to Heroku but won't run
  • Loop animation drawable
  • Gray line inside cardview :)?
  • Upgrade project from WorkLight 6.1 to MobileFirst 7.1
  • How to enable mapping the private property of the entity
  • Wrapping text in spinner android
  • TFS - how do I sum child task hours to parent
  • What is corresponding c++ data type to SQL numeric(18,0) data type?
  • How to resolve permission denied maybe missing internet permission?
  • Deploying a CodeRush plugin from the Community Site
  • How to pass solution folder as parameter in command line arguments (for debug)?
  • Do query loads all the data in memory
  • Roxygen error “Skipping invalid path”
  • Handling un-mapped Rest path
  • Xamarin Forms - UWP Fonts
  • Installing Hadoop, Java Exception about illegal characters at index 7?
  • HTML download movie download link
  • Convert array of 8 bytes to signed long in C++
  • jquery mobile loadPage not working
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to get icons for entities from eclipse?
  • Proper way to use connect-multiparty with express.js?
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • -fvisibility=hidden not passed by compiler for Debug builds
  • coudnt use logback because of log4j
  • JaxB to read class hierarchy
  • Net Present Value in Excel for Grouped Recurring CF