I'm using the C interface for XPC services; incidentally my XPC service runs very nicely asides from the following problem.
The other day I tried to send a "large" array via XPC; of the order of 200,000 entries. Usually, my application deals with data of the order of a couple of thousand entries and has no problems with that. For other uses an array of this size may not be special.
Here is my C++ server code for generating the array:
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);
and here is the client code:
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);
}
If I try to handle a large array I get a seg fault (SIGSEGV)
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libxpc.dylib 0x00007fff90e5cc02 xpc_array_get_count + 0
When you say "extremely big array" are you speaking of something that launchd might regard as a resource-hog and kill?
XPC is only really meant for short-fast transactional runs rather than long-winded service-based runs.
If you're going to make calls that make launchd wait, then I'd suggest you try https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
When the Service dies.. Are any specific events other then SIG_ABORTS etc... fired?
Do you get "xpc service was invalidated" (which usually means launchD killed it, or did you get "xpc service/exited prematurely" which usually is handler code error.