安全的垃圾收集 [英] Safe garbage collecting

查看:112
本文介绍了安全的垃圾收集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我正在尝试实施一个安全的垃圾收集系统。我使用

引用计数结合智能指针和垃圾收集器

保存所有堆分配对象的列表。现在我还有

问题来区分堆栈和堆分配的对象(参见

也是确定对象是否已使用operator new分配)。

我可以选择禁止多个/虚拟继承(坏)

OR禁止堆栈分配的对象并直接嵌入对象

(更糟)。

看来我不能解决这些问题,所以我想知道是否

那里是内存管理的另一个概念。任何提示或指示

表示赞赏。


TIA,

罗伯特

解决方案



" Robert Potthast"写道:

现在我还有问题要区分
堆栈和堆分配的对象



检查是否这个 ;价值在里面

堆栈范围。它可以方便快捷地完成。


/ Pavel




Pavel Vozenilek < PA ************* @ yahoo.co.uk>在消息中写道

news:3o ************ @ individual.net ...


" Robert Potthast"写道:

现在我还有问题要区分
堆栈和堆分配的对象


检查this是否为this。值在里面堆栈范围。它可以轻松快速地完成。




它很容易找到堆栈的顶部,但我知道没有便携的方式来

找到它的底部。如果我错过了什么,请告诉我!




" Walter Bright"写道:

" Robert Potthast"写道:

>现在我还有问题需要区分
>堆栈和堆分配的对象
>


检查this是否为this。值在里面堆栈范围。它可以轻松快速地完成。



很容易找到堆栈的顶部,但我知道没有便携的方法来找到它的底部。如果我错过了什么,请告诉我!




好​​吧,我假设垃圾收集在main()之后启动了

是此时输入和当前堆栈顶部

存储为全局变量。


/ Pavel


Hi!
I am trying to implement a safe garbage collecting system. I use
reference counting combined with smart pointers and a garbage collector
which keeps a list of all heap-allocated objects. Now I still have the
problem to distinguish between stack and heap allocated objects ( see
also "Determining if object has been allocated using operator new" ).
I either have the choice to disallow multiple/virtual inheritance (bad)
OR disallow stack allocated objects and directly "embedded" objects
(worse).
It seems I won''t be able to solve those problems, so I want to know if
there is another concept for memory management. Any hints or pointers
are appreciated.

TIA,
Robert

解决方案


"Robert Potthast" wrote:

Now I still have the problem to distinguish between
stack and heap allocated objects


Check whether the "this" value is inside
stack range. It can be done portable and quickly.

/Pavel



"Pavel Vozenilek" <pa*************@yahoo.co.uk> wrote in message
news:3o************@individual.net...


"Robert Potthast" wrote:

Now I still have the problem to distinguish between
stack and heap allocated objects


Check whether the "this" value is inside
stack range. It can be done portable and quickly.



It''s easy to find the top of the stack, but I know of no portable way to
find the bottom of it. If I''ve missed something, please let me know!



"Walter Bright" wrote:

"Robert Potthast" wrote:

> Now I still have the problem to distinguish between
> stack and heap allocated objects
>


Check whether the "this" value is inside
stack range. It can be done portable and quickly.



It''s easy to find the top of the stack, but I know of no portable way to
find the bottom of it. If I''ve missed something, please let me know!



OK, I assumed garbage collection kicks in after main()
is entered and the current-top-of-stack at the moment
is stored as global variable.

/Pavel


这篇关于安全的垃圾收集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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