5

The general NSPasteboard stores stuff that the user has copied. For example, like 100 images and 1000 words. Is there a limit to the size of the general NSPasteboard such that the user can copy say.. 99 images maximum?

What defines this limit? RAM or HD or ..?

hollow7
  • 1,506
  • 1
  • 12
  • 20

1 Answers1

4

Yes.

There's no documented enforced limit (that I could find) on the size of the pasteboard. However, everything is finite. If you copy too much stuff to any pasteboard (whether it's the general pasteboard, the Find pasteboard, a drag pasteboard, or any other), you'll either hit an undocumented limit or you'll drive the system into paging hell. (Even that last part isn't really guaranteed; the pasteboard uses RAM the last time I checked, but it theoretically could write to disk instead either now or in the future.)

If you plan on copying a large quantity of data, I suggest promising it instead. How you do that depends on whether you're using the older type-and-data-based API, or the newer item-based API. It's more work, but it means you'll only need to bring in that data when the user pastes it somewhere.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • 4
    Just to clarify, promising means that instead of sending the data to the pasteboard immediately, you send a promise that you will send the data when it's actually required (e.g. when the user actually uses the Paste command). Generally you would also need to supply the data when your app will quit, but you can prompt the user to see if they want to discard the pasteboard if the data is very large, which is what Photoshop does. – Rob Keniger Nov 28 '11 at 00:48
  • 1
    Just to clarify, I'm not claiming that Photoshop is a paragon of user interaction design(!), but it does handle very large clipboard content correctly, in my opinion. – Rob Keniger Nov 28 '11 at 01:05