CPU raises with attributesOfItemAtPath:error:

☆樱花仙子☆ 提交于 2019-12-01 10:23:36

问题


I am using [NSFileManager attributesOfItemAtPath:error:] function for fetching attributes of file. But sometimes my application cpu is going upto 100%. I am using this function for 100k(approx.) files.
Sample of my application:

                                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  

Can anyone please help me out?


回答1:


I am using stat.

#import <sys/stat.h>

struct stat stat1;
if( stat([inFilePath fileSystemRepresentation], &stat1) )
      // something is wrong 
long long size = stat1.st_size;
printf("Size: %lld\n", stat1.st_size);



回答2:


  • SYSENTER is a companion instruction to SYSEXIT. The trap is a subset of a thread’s complete context. So, the trap frame keeps information about the current thread context so it could restore it with SYSEXIT instruction.

Link about Sysenter_traps.

It seems that you are overloading your main thread. Thats why Cpu is on 100%



来源:https://stackoverflow.com/questions/10580422/cpu-raises-with-attributesofitematpatherror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!