如何获取在变量中分配的堆的地址 [英] How to get addres of heap assigned in variable

查看:66
本文介绍了如何获取在变量中分配的堆的地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在创建一个对象:

 MyClass a =  MyClass(); 


我想获取对象a中存在的地址.
表示它指向哪个内存位置

解决方案

我认为它将被分配以xx00ee八进制或十六进制格式的内存地址


在不安全模式下,请使用& ;.

通常,您可以创建 GCHandle [ ^ ],类型为Pinned的任何对象,然后在其上调用AddrOfPinnedObject来查找它的固定位置.

但是除了调试一些非常技术性的互操作内容外,您永远不需要这样做.因此,您确实需要解释为什么您认为需要此值,因为几乎肯定不是这种情况.


hi
I am creating an object:

MyClass a= new MyClass();


I want to get what adress is present in object a.
mean to which memory location it is pointing

解决方案

i think it will get assigned with memory address like xx00ee octal or hexadecimal format


In unsafe mode, use &.

Normally, you can create a GCHandle[^], of type Pinned, to any object and then call AddrOfPinnedObject on it to find where it was pinned.

But you should never need to do this, except for debugging some very technical interop stuff. So you really need to explain why you think you need this value, because it''s almost certainly not the case.


这篇关于如何获取在变量中分配的堆的地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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