Re: [glib] malloc and bdwgc

Mono is a project using both bdwgc and glib (or say their eglib), but I didn't figure out how they managed to put these two together.

So if I'm using basic data structures in glib to create my own data structure that needs garbage collection due to possible runtime circular dependency, what is the best way to do it? And is rebuilding glib with gc-friendly necessary?

Krzysztof Kosiński <tweenk pl gmail com>于2016年1月12日周二 上午11:42写道:

On Jan 11, 2016 7:03 PM, "张海" <dreaming in code zh gmail com> wrote:
> Yes, but the point of my previous email is that the third-party GC_malloc() might eventually call malloc() itself, and by defining a malloc() in my program, GC_malloc() will again call into my malloc() and then GC_malloc() until stack overflow. Do you think this will happen?

One possible solution is to use something like libunwind to look at the call stack. If your malloc detects it is called recursively, call __libc_malloc instead of GC_malloc.

> Meanwhile since glib provides basic data structures for developers to build their own data structure upon, and developers should be able to decide which allocator their own data structure should use, I still think a GMemVTable should be conceptually necessary. Is there anything that prevents this from being implemented, for example with a g_mem_vtable_init_hook() function? (Are weak symbols possible to be portable? Or if not, missing such feature will still prevent many applications from migrating to the new version of glib.)

It looks like almost nobody used this feature, and it had a performance impact, so it was removed.

浙江大学 计算机科学与技术

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]