Code like this:
NSData *data = [NSMutableData dataWithLength:20*1024*1024];
UIPasteboard* genePasteboard = [UIPasteboard generalPasteboardSwizzle];
genePasteboard.items = @[@{@"test":data}]; //P1
NSLog(@"%d", (int)[genePasteboard.items count]); //P2
NSArray<NSDictionary<NSString *, id> *> *items = genePasteboard.items //P3
At P1 the memory usage increases 20MB, it's easy to understand, however, P2 and p3 will increase 20MB too. i printed the address of items and genePasteboard.items, those two are not same, it means every time I ref to genePasteboard.items, it will copy whole items?
Another question I have is: when I use code like this to clear UIPasteboard:
genePasteboard.items = @[@{}];
The memory usage will not decrease immediately, only when I continue the process, it will release at sometime(guess in the next main loop?), so, How can i know when the genePasteboard.items memory is release or can I release it immediately?