Android Runtime(ART)中用于本机和Java的统一堆栈 [英] Unified stack for native and Java in Android Runtime (ART)

查看:217
本文介绍了Android Runtime(ART)中用于本机和Java的统一堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

https://developer.android.com/guide/实践/verifying-apps-art.html#Stack_Size

该文档说ART具有针对本机和Java的统一堆栈。
你能告诉我这是什么意思吗?
我知道线程的堆栈大小只能在创建时定义,例如在Java代码中使用Thread类的构造函数或在本机代码中使用pthread API。
所以我不明白统一堆栈如何影响应用程序的行为。
请指导我一些统一的堆栈导致的一些好的教程或代码片段StackOverflowError。

This document says that the ART has a unified stack for native and Java. Could you tell me what does it mean? I understand that thread's stack-size can be defined only when it is created, e.g. using constructor of Thread class in Java code or pthread API in native code. So I can not understand how does unified stack affect behavior of applications. Please direct me to some good tutorials or snippet throws StackOverflowError resulted from unified stack.

推荐答案

在Dalvik中,每个线程有两个单独的堆栈,一个用于本机代码,另一个用于Java代码。在ART中,每个线程都有一个用于本机代码和Java代码的堆栈。如果在代码中的某个位置(本机或Java)创建了一个线程并指定了它的堆栈大小,则您现在应该知道两个代码环境都共享该大小,并应进行相应的调整。

In Dalvik, each thread have a two separate stacks, one for the native code and for the Java code. In ART each thread have one stack for both native code and the Java code. If somewhere in your code (native or Java) you created a thread and specified it's stack-size, you should be aware now that this size is shared for both code environments, and you should adjust it accordingly.

这篇关于Android Runtime(ART)中用于本机和Java的统一堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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