在运行时检测C ++中堆碎片的可移植方法? [英] Portable way to detect heap fragmentation in c++ at runtime?

查看:113
本文介绍了在运行时检测C ++中堆碎片的可移植方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个基于qt的c ++应用程序,我需要能够检测内存碎片,以便检查当前系统是否真正能够承受内存负载:该程序加载了一张大图像(15/21兆像素规范)存储在内存中,然后对其进行一些过滤(带有稀疏矩阵). 例如,我在Windows中遇到内存碎片问题,VMMap在此方面非常有帮助:问题是某些DLL(Wacom平板电脑"wintab32.dll"和UltraMon应用程序)没有被重新定位,因此正在拆分地址空间在进程的0x10000000-0x30000000 VA处.

I'm writing a qt-based c++ application and i need to be able to detect memory fragmentation in order to check if the current system can actually sustain the memory load: the program load a big image (15/21 megapixels are the norm) in memory and then perform some filtering on it (w/ sparse matrices). For instance, i'm having memory fragmentation problem in Windows and VMMap has been very helpful in this: the problem was some DLLs (Wacom tablet "wintab32.dll" and the UltraMon app) doesn't get relocated so are splitting the address space at the 0x10000000-0x30000000 VA of the process.

我想让应用程序对碎片问题有所了解,并想知道提供VMMAP信息的跨平台(linux/mac/win32)方法是否已经存在.

I want to provide the application with some sort of awareness toward the fragmentation problem and wondering if a cross-platform (linux/mac/win32) approach giving the information VMMAP gives already exist.

推荐答案

简短答案:没有可移植的方法.

Short answer: There is no portable way.

更长的答案:堆的实现方式和工作方式是您的实现的实现细节,在平台,标准库和操作系统之间差异很大.您必须为每个实现创建一个不同的版本-提供的实现为您提供了一个可以插入其中的API. (我认为 应该针对您所针对的三个平台.)

Longer answer: How the heap is implemented and how it works is an implementation detail of your implementation that widely differs between platforms, std libraries, and operating systems. You'll have to create a different version for each implementation - provided, the implementation gives you an API to hook into it. (Which I think should be the case for the three platforms you target.)

这篇关于在运行时检测C ++中堆碎片的可移植方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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