gpt4 book ai didi

c++ - 识别主要页面错误原因

转载 作者:IT王子 更新时间:2023-10-29 00:32:23 25 4
gpt4 key购买 nike

我被要求查看一个用 C++ 编写并在 Linux 上运行的内部应用程序,它有一些困难。它会周期性地出现大量的主要页面错误(~200k),这会导致挂钟运行时间增加 x10+,然后在某些运行中它会没有。

我尝试过隔离不同的代码片段,但在测试时却很难重复页面错误。

对于从应用程序/Linux 中获取有关主要页面错误的更多信息,是否有人有任何建议?我只有一个总数。

最佳答案

您可以考虑 Valgrid ,在主页上描述为:

Valgrind is an instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail. You can also use Valgrind to build new tools.

特别是 Valgrind 包含一个名为 Massif 的工具, 手册中给出了以下(解释的)概述:

Massif is a heap profiler. It measures how much heap memory your program uses. [..]

Heap profiling can help you reduce the amount of memory your program uses. On modern machines with virtual memory, this provides the following benefits:

  • It can speed up your program -- a smaller program will interact better with your machine's caches and avoid paging.

  • If your program uses lots of memory, it will reduce the chance that it exhausts your machine's swap space.

关于c++ - 识别主要页面错误原因,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4267006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com