我爲XPC服務使用C接口;順便說一句,我的XPC服務運行非常好,從以下問題旁邊。XPC服務陣列崩潰
有一天我試圖通過XPC發送一個「大」數組;大約200,000個條目。通常,我的應用程序處理數千條數據的順序數據,並且沒有任何問題。對於其他用途,這個大小的數組可能並不特殊。
這裏是產生陣列我的C++服務器代碼:
xpc_connection_t remote = xpc_dictionary_get_remote_connection(event);
xpc_object_t reply = xpc_dictionary_create_reply(event);
xpc_object_t times;
times = xpc_array_create(NULL, 0);
for(unsigned int s = 0; s < data.size(); s++)
{
xpc_object_t index = xpc_uint64_create(data[s]);
xpc_array_append_value(times, index);
}
xpc_dictionary_set_value(reply, "times", times);
xpc_connection_send_message(remote, reply);
xpc_release(times);
xpc_release(reply);
和這裏的客戶端代碼:
xpc_object_t times = xpc_dictionary_get_value(reply, "times");
size_t count = xpc_array_get_count(times);
for(int c = 0; c < count; c++)
{
long my_time = xpc_array_get_uint64(times, c);
local_times.push_back(my_time);
}
如果我試圖處理大陣,我收到了賽格故障( SIGSEGV)
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libxpc.dylib 0x00007fff90e5cc02 xpc_array_get_count + 0
過量進食是在聖誕節的時候一個常見的問題 –
那麼每個條目的大小是多少?只有當條目數量很大時才能看到這個數字,例如2lakh?看起來像堆棧溢出 – Gopi