你会如何​​找出如果一台机器的堆栈是向上或向下的记忆? (JAVA) [英] How would you find out if a machine’s stack grows up or down in memory? (JAVA)

查看:139
本文介绍了你会如何​​找出如果一台机器的堆栈是向上或向下的记忆? (JAVA)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C程序来检查机器是否栈或下长大在内存中。

I have a C program to check whether the machine stack is growing up or down in memory in.

它是这样的:

#include <stdio .h>

void sub(int *a) {
 int b;

 if (&b > a) {
 	printf("Stack grows up.");
 } else {
	printf("Stack grows down.");
 }
}

main () {
 int a;
 sub(&a);
}

现在我想要做Java中的相同。 : - )

Now i want to do the same in Java. :-)

任何人知道,而无需编写任何本地code的解决方案?

Any one knows a solution without writing any native code ???

感谢

推荐答案

如果你没有做任何本地code,那么我无法想象的情况下它可能用纯Java code没关系。毕竟,Java堆栈可能在任何方向被分配在所有而不是被存储器的严格连续块(象机栈)。

If you're not doing any native code, then I can't imagine a situation where it could possibly matter in pure Java code. After all, the Java stack might be allocated in any direction at all instead of being a strictly contiguous block of memory (like the machine stack).

这篇关于你会如何​​找出如果一台机器的堆栈是向上或向下的记忆? (JAVA)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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