Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 为什么OSX核心文件这么大?_Macos_Memory_Clang - Fatal编程技术网

Macos 为什么OSX核心文件这么大?

Macos 为什么OSX核心文件这么大?,macos,memory,clang,Macos,Memory,Clang,我有一个简单的程序: #include <iostream> int main() { std::cout << "Starting" << std::endl; while (1) { } return 0; } 在另一个终端,我检查并杀死它: bash$ top Processes: 284 total, 3 running, 9 stuck, 272 sleeping, 1505 threads

我有一个简单的程序:

#include <iostream>

int main() {
    std::cout << "Starting" << std::endl;
    while (1) {
    }

    return 0;
}
在另一个终端,我检查并杀死它:

bash$ top

Processes: 284 total, 3 running, 9 stuck, 272 sleeping, 1505 threads                       14:45:49
Load Avg: 1.86, 1.81, 2.06  CPU usage: 13.57% user, 0.96% sys, 85.45% idle
SharedLibs: 21M resident, 12M data, 0B linkedit.
MemRegions: 87372 total, 4974M resident, 86M private, 1203M shared.
PhysMem: 15G used (1887M wired), 1450M unused.
VM: 729G vsize, 1064M framework vsize, 3299196(0) swapins, 3711511(0) swapouts.
Networks: packets: 2686338/648M in, 2068186/355M out.
Disks: 1141818/44G read, 1926370/100G written.

PID    COMMAND      %CPU  TIME     #TH   #WQ  #PORT MEM    PURG   CMPRS  PGRP  PPID  STATE
30161  test         100.3 02:12.71 1/1   0    9     312K   0B     0B     29470 28181 running
66064  Terminal     2.7   01:29.69 9     3    257   53M    0B     4580K  66064 1     sleeping


bash$ ls -al /cores/
total 917024
drwxrwxr-t@  3 root    admin        102 May  1 14:54 .
drwxr-xr-x  33 root    wheel       1190 Apr 14 09:13 ..

bash$ killall -SIGSEGV test

bash$ ls -al /cores/
total 1818048
drwxrwxr-t@  4 root    admin        136 May  1 14:55 .
drwxr-xr-x  33 root    wheel       1190 Apr 14 09:13 ..
-r--------   1 stebro  admin  469516288 May  1 14:54 core.30161
vmmap说:

==== Summary for process 50745
ReadOnly portion of Libraries: Total=316K resident=280K(89%) swapped_out_or_unallocated=36K(11%)
Writable regions: Total=40.3M written=16K(0%) resident=12.1M(30%) swapped_out=14.4M(36%) unallocated=28.3M(70%)

REGION TYPE                      VIRTUAL
===========                      =======
Kernel Alloc Once                     4K
MALLOC                             9388K        see MALLOC ZONE table below
MALLOC (admin)                       24K
STACK GUARD                        56.0M
Stack                              8192K
VM_ALLOCATE                           4K
__DATA                              680K
__LINKEDIT                         70.9M
__TEXT                             5960K
shared memory                         4K
===========                      =======
TOTAL                             150.6M

                                 VIRTUAL ALLOCATION      BYTES
MALLOC ZONE                         SIZE      COUNT  ALLOCATED  % FULL
===========                      =======  =========  =========  ======
DefaultMallocZone_0x104a0e000      9216K        357        27K      0%

为什么我的核心文件是469 MB?

您的核心转储包括完整的内存状态以及应用程序运行时使用的框架和库的符号信息。这是大量的数据。要了解更多信息,您可以查看上面示例中的

的核心转储部分,我使用的框架或库可能是C运行时之外的。这似乎不太可能是一个近500MB的内存占用。我对Solaris更为熟悉,在Solaris中,像这样的应用程序可能会生成一个不超过1兆字节的核心文件,但您必须确保您拥有原始二进制文件&libs来正确解释核心文件。从您的链接来看,OSX似乎没有这样的选项。因为在我们的案例中,当自动测试失败时,核心文件被用作诊断工具,我们应该使用类似“sample 20821 2-file/tmp/stack.txt”的东西来切换以收集我们需要的;堆栈跟踪应该足够用于我们的目的。重要的是,如果您使用的框架不是,那么它们就映射到运行的应用程序的虚拟内存空间中,以防您(或标准C++运行时)可能需要它们。如果您查看技术说明,它明确提到Mac OS X内核转储异常大。@SteveBroberg:要了解更多信息,请尝试在您的进程上应用
vmmap-w-interleave
。@Kenthomass:请参阅我对上述问题的编辑;vmmap提供了一些细节,但仍有大约300MB的数据未被解释。
==== Summary for process 50745
ReadOnly portion of Libraries: Total=316K resident=280K(89%) swapped_out_or_unallocated=36K(11%)
Writable regions: Total=40.3M written=16K(0%) resident=12.1M(30%) swapped_out=14.4M(36%) unallocated=28.3M(70%)

REGION TYPE                      VIRTUAL
===========                      =======
Kernel Alloc Once                     4K
MALLOC                             9388K        see MALLOC ZONE table below
MALLOC (admin)                       24K
STACK GUARD                        56.0M
Stack                              8192K
VM_ALLOCATE                           4K
__DATA                              680K
__LINKEDIT                         70.9M
__TEXT                             5960K
shared memory                         4K
===========                      =======
TOTAL                             150.6M

                                 VIRTUAL ALLOCATION      BYTES
MALLOC ZONE                         SIZE      COUNT  ALLOCATED  % FULL
===========                      =======  =========  =========  ======
DefaultMallocZone_0x104a0e000      9216K        357        27K      0%