- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 Doug Lea's dlmalloc memory allocator .但是,当我使用它时,我得到了 segmentation 。如果我使用普通的 malloc,我的程序运行良好。我记得我曾经读到你需要先调用一些初始化函数才能使 dlmalloc 工作,但我现在不记得是哪个函数了。我试图查看评论以找出哪个功能,但仍然找不到。
最佳答案
来自分配器源代码中的注释:
Tread-safety: NOT thread-safe unless USE_LOCKS defined non-zero
When USE_LOCKS is defined, each public call to malloc, free, etc is surrounded with a lock. By default, this uses a plain pthread mutex, win32 critical section, or a spin-lock if if available for the platform and not disabled by setting USE_SPIN_LOCKS=0.
您需要使用 USE_LOCKS
编译库,否则您可能会看到崩溃。
另一种可能性是您的程序表现出未定义的行为,不会导致常规 malloc
的后果。例如,它可能会在某处的分配区域后写入一个字节,但该字节可能是比您请求的大几个字节的内存块的一部分。在将程序与自定义分配器链接之前,使用 valgrind 检查您的程序是否存在“常规”malloc 内存错误。
关于c - 使用 dlmalloc 的段错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11308339/
我正在阅读 Doug Lea 的内存分配器 here .我找到了以下宏来计算要添加到地址以使其对齐的偏移量。 /* The bit mask value corresponding to MALLOC
下面是dlmalloc算法的详细说明:http://g.oswego.edu/dl/html/malloc.html dlmalloc block 由一些元数据预订,其中包括有关 block 中空间量
我正在使用 Doug Lea's dlmalloc memory allocator .但是,当我使用它时,我得到了 segmentation 。如果我使用普通的 malloc,我的程序运行良好。我记
在 glibc malloc.c 或 dlmalloc 中说“repositioning tricks”如 blew,并在 bin_at 中使用此技巧。 bins是一个数组,空间是在分配av(stru
[我已经解决了这个问题——请参阅下面我的最后一条评论。] 在我的应用程序中,我需要使用自己的特殊 malloc,基于 Doug Lea 的 dlmalloc:我映射一个匿名文件(使用 mmap),从映
为了在 dalvik 堆中分配内存区域,应用程序使用 dlmalloc,而不是普通的 malloc,为什么使用 dlmalloc,以及它与 malloc 的区别。 (据我所知,为了在创建 dalvik
一段时间以来,我一直很高兴地使用 dlmalloc对于跨平台项目(Windows、Mac OS X、Ubuntu)。然而,最近似乎使用 dlmalloc 会导致 Windows 7 上的退出时崩溃。
我正在使用 gnu sparc 工具链。我有 sparc-ab-elf-gcc 和 sparc-ab-linux-gcc。 (“ab”是处理器名称)。我想在裸机(没有操作系统)上编译一个使用 mall
我想知道是否有人可以澄清以下内容:如果我没记错的话,fd 是指向 bin 中下一个 malloc_chunk 结构的指针,但我也看到它被指定为指向 malloc_chunk 结构中的 fd 字段的指针
我已经有一段时间没有编码了,所以先打扰一下。我有这个奇怪的问题。我正在尝试一次性 malloc 8GB,我计划稍后使用 TLSF 管理该堆。也就是说,我想完全避免在我的应用程序中进行 mallocin
我正在尝试将 dough lea 的 malloc (malloc.c) 集成到 native WP8 应用程序中。 将 dlmalloc.c 文件添加到 Windows Phone 的 MVS 20
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 6 年前。 Improve t
因为在我考虑在此发布问题和我的解决方案之前找不到任何人报告此行为,以便它可以帮助遇到此问题的其他人。我们的应用程序在 ICS 之前的设备上运行良好。我们在 Galaxy Nexus 和 ICS 模拟器
我是一名优秀的程序员,十分优秀!