Android的NDK:Dalvik的堆和本机堆 - 如何在这两者之间独立 [英] Android NDK: Dalvik Heap and Native Heap - How Separate Between the two

查看:298
本文介绍了Android的NDK:Dalvik的堆和本机堆 - 如何在这两者之间独立的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有Dalvik的(JVM)堆和本机堆在android平台。
和Dalvik的GC对本机堆没有工作。
但我不知道这是如何工作的,我的意思是如何的Andr​​oid操作系统将它们分开?

I know there's Dalvik(JVM) heap and Native heap in an android platform. And the Dalvik GC has no work on native heap. But I'm not sure how this work, I mean how the Android OS separate them?

可能的情况下1:由独立的内存硬件组成的(我不相信很多)

possible situation 1: composed by separate memory hardware (I don't believe much)

可能的情况下2:Android操作系统有固定的内存量为堆

possible situation 2: Android OS has FIXED amount of memory for both heap

可能发生的情况。3:Android操作系统已分配的Dalvik堆内存的一部分,在必要的时候,成为本机堆,所以本机堆和Dalvik的堆的大小是灵活的。

possible situation 3: Android OS has to allocate part of Dalvik memory heap to become native heap when necessary, and so the size of native heap and Dalvik heap is flexible.

哪一个是真实的,或者说我没有提到可能性?

Which one is true, or possibility that I didn't mention?

推荐答案

本机堆是由管理​​dlmalloc(),它使用 mmap()的和标准要求,比如 SBRK()来分配内存。托管(的Dalvik)堆是分配(主要是)一个大的块的mmap()。这是在Linux内核之上所有正在运行的,因此,如果您了解Linux的内存管理,那么你已经知道了较低级别的部分是如何运作。

The native heap is managed by dlmalloc(), which uses a combination of mmap() and standard calls like sbrk() to allocate memory. The managed ("Dalvik") heap is (mostly) one large chunk allocated with mmap(). It's all running on top of the Linux kernel, so if you understand Linux memory management then you already know how the lower-level parts work.

您可以阅读更多关于Dalvik的是如何返回从托管堆到操作系统中的这个帖子

You can read more about how Dalvik returns empty pages from the managed heap to the OS in this post.

编辑:的规范后的信息,关于Android的内存管理是<一个href=\"http://stackoverflow.com/questions/2298208/how-to-discover-memory-usage-of-my-application-in-android\">this 之一。我不认为它直接回答你的问题,但它有很多很好的信息和链接信息的网站。

the canonical post for information about Android memory management is this one. I don't think it directly answers your question, but it has a lot of good information and links to informative sites.

这篇关于Android的NDK:Dalvik的堆和本机堆 - 如何在这两者之间独立的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆