CPU raises with attributesOfItemAtPath:error:



我正在使用[NSFileManager attributesOfItemAtPath:error:]函数来获取文件的属性。但有时我的应用程序 CPU 会达到 100%。我正在将此功能用于 100k(大约)文件。
我的应用程序示例:

                                2128 -[NSFileManager attributesOfItemAtPath:error:]
                                  2128 +[NSFileAttributes _attributesAtPath:partialReturn:filterResourceFork:error:]
                                    2123 _attributesAtPath
                                      2072 listxattr
                                      29 realloc
                                        18 realloc
                                        11 szone_size
                                      22 _attributesAtPath
                                    5 _sysenter_trap  

谁能帮帮我?

我正在使用stat.

#import <sys/stat.h>
struct stat stat1;
if( stat([inFilePath fileSystemRepresentation], &stat1) )
      // something is wrong 
long long size = stat1.st_size;
printf("Size: %lldn", stat1.st_size);
  • SYSENTERSYSEXIT的配套说明。陷阱是线程完整上下文的子集。因此,陷阱帧保留有关当前线程上下文的信息,以便它可以使用 SYSEXIT 指令恢复它。

关于Sysenter_traps的链接。

似乎您的主线程超载了。这就是为什么 CPU 处于 100% 状态的原因

最新更新