top | item 31667701

Is there a maximum size for Windows clipboard data?

269 points| kencausey | 3 years ago |devblogs.microsoft.com

166 comments

order
[+] bombcar|3 years ago|reply
> over 300,000 rows

Any process you ever enable in code will be pushed to limits you never dreamed possible. This is exactly where discoverability can come into play - someone starts by copying 50 rows and using that to get their job done, and may never realize there are other ways (CSV export, etc).

If code can "recognize" when something like this is being done and provide documentation on other ways, it can help people learn new methods.

[+] Arrath|3 years ago|reply
> If code can "recognize" when something like this is being done and provide documentation on other ways, it can help people learn new methods.

Now I'm imaging Clippy popping up when you copy a ludicrous amount of data to the clipboard. "You appear to be using a cludgy method, may I suggest something better?"

Of course, I'm guilty of things like this. I have one excel macro that splits data from a giant stream* (one monolithic CSV, actually) into discrete units, graphs them, and then sorts the graphs for printing. It makes a lot of use of the clipboard, and god help you if you try to copy/paste something while the macro is running.

*Giant enough that at one point it grew to where I overran my Int and had to upgrade some of the code to Longs :V

[+] cnity|3 years ago|reply
This is a chicken and egg problem. This limit seems impossibly high because users lack the expectation they can perform this action, because designers of software don't expect users to perform this action, because users lack the expectation they can...

I disagree with sibling comments that copy/paste is a hacky solution. It's a very natural one for lots of users and there's no actual fundamental reason not to be able to accommodate it.

[+] markmark|3 years ago|reply
Visual Studio used to (or maybe still does) have an issue where it wouldn't hit breakpoints after the 65,536th line in a source file. It wasn't something I ever encountered, I just came across the issue in the docs somewhere, but I pity the person that ran into it.
[+] treeman79|3 years ago|reply
Filed a bug report once. App crashes when font is more then 13,000 points.

There was a long discussion on memory management before they just stuck a max size on it.

[+] babypuncher|3 years ago|reply
Some video games have tutorial systems similar to this. They will recognize when players are struggling with a certain mechanic or system, and pop up a relevant tutorial. i.e. if a user is trying and failing to jump across a gap, they probably forgot to use their hover boots.

This can get annoying though if the user is deliberately doing something that ends up triggering these messages.

[+] tomcam|3 years ago|reply
> Any process you ever enable in code will be pushed to limits you never dreamed possible.

Not me. And that’s not a brag. It is probably not a productive way to think using modern toolsets. But in my world, if you can copy a few things, you should definitely expect someone to copy a shitload of things or at the very least, document clearly and with rich error messages what went wrong.

Likewise, I tend to get nervous when I can’t explicitly handle out of memory conditions, and the problem is I’m a Go programmer. It kind of bothers me that there’s no standard way to deal with that on my end with built-in data structures such as maps and strings. This is probably sheer paranoia because most modern systems have plenty of memory… But it still leaves me uneasy.

[+] sprremix|3 years ago|reply
> This is known as clipboard delay-rendering

Aha, so that's why Word[1] just explicitly asked me if I want to save the current copied image before quitting. It's probably asking before loading something big into memory?.

[1] https://i.imgur.com/sNfE3Be.png

[+] naikrovek|3 years ago|reply
no, it's that what you believe to be in your clipboard is not actually in your clipboard, and Word is asking if you want to have that data after it closes and can no longer populate the clipboard.

it has nothing to do with clearing memory.. clearing memory for anticipated use isn't really a thing ever since virtual memory became a thing. (memory isn't prepared for use until after an application actually tries to use it.)

[+] bobbylarrybobby|3 years ago|reply
Yep, Excel does something similar where it asks you "you have a large selection copied [(marching ants)], do you want to keep it available after closing Excel?"
[+] adenverd|3 years ago|reply
Side note/feel good moment: the author Raymond Chen is an OG beyond-super-engineer at Microsoft, and is an incredible person to work with. He assisted me with my intern project many years ago, and was amazingly eager to share his wealth of experience with a green-eared intern from outside his org.

Thanks Raymond! I decided to go the startup route instead of returning to MSFT, but you were an inspiration all the same.

[+] hoseja|3 years ago|reply
His "people send us dumb vulnerability reports" series seems quite arrogant to me, with new severe hole being found in Windows every other week.
[+] dragontamer|3 years ago|reply
The Windows Clipboard, for all of its problems, remains one of the easiest program-to-program communication methods to use in modern GUIs.

I can take a screenshot of my Firefox with "PrtScn" button (moving a bitmap of the page into the Clipboard), paste it into Microsoft Paint, edit it a bit, and then copy/paste that into my Discord chat screen for commentary.

--------

Yes, Linux / *Nix users have pipes and great text processing tools. Yes, Powershell has interesting objects that can be passed round. But practically speaking? Most of my "inter-process communications" is over this silly "Clipboard" Windows has, and it works way better than it probably should.

[+] magicalhippo|3 years ago|reply
Even better, you can copy an attachment in a mail in Outlook, and paste it into an application running on another computer via RDP. The file will be copied over without the applications knowing any better.

We use this so users can attach invoices and other documents they've received through mail to orders in our application. Users typically run Outlook on their laptop/PC, but our application as a published application.

We rely on Excel exposing the data in an XML format on the clipboard to reliably import data from Excel. Same for Open/LibreOffice. Without it it's impossible to handle cells which contain both the quote character and newlines, due to the way Excel formats plaintext.

We don't want to import the whole file, because the users typically only need to import parts of the spreadsheet. This saves us from writing a complex UI to select the data to import.

And FWIW, I've used that with >100k rows of data.

[+] com2kid|3 years ago|reply
I've had the pleasure of looking at the Windows source code for the clipboard.

Insanely well engineered. It can perform miracles of computing. It damn well has to.

> I can take a screenshot of my Firefox with "PrtScn" button (moving a bitmap of the page into the Clipboard), paste it into Microsoft Paint, edit it a bit, and then copy/paste that into my Discord chat screen for commentary.

All without you worrying about supported image formats or color space encodings! It is insane! Copy from Firefox and then paste into a program that expects 16bit color and it'll probably work. The clipboard stores data in so many duplicate formats and can convert between so many formats, it is nuts.

[+] MikeSchurman|3 years ago|reply
I've found the clipboard to be a highly flexible tool, that seems under-used. As an example, I've extended my game engine editor to draw any position in 3d that I have in the clipboard. So when problems happen and are displayed in the logs, I select the log, copy to clipboard, boom, position drawn.

This idea has a lot of legs IMO.

[+] ryandrake|3 years ago|reply
I haven't been keeping up with the Windows world. Does Microsoft provide any safeguards or tools for the user to limit access to the clipboard? The clipboard was introduced in the good ol' days when you could basically trust the applications running on your computer. Nowadays, third party (and for those of us more paranoid) first party apps need to be considered attackers. The clipboard is a juicy target that often contains sensitive data I'm sure most apps would like to gobble up and exfiltrate. I know iOS and Android both are starting to introduce restrictions on mobile apps' use of the clipboard. Has this made it into the Windows desktop world?
[+] lemoncookiechip|3 years ago|reply
Unrelated, but you can actually use Firefox's own screenshot function which is far more robust than PrtScn, allowing you crop the image how you want (including snap to element), you can also save to clipboard or download it for further editing or storing. The key-shortcut is CTRL+LSHIFT+S.
[+] banana_giraffe|3 years ago|reply
It's cute just how old the concept of the Windows Clipboard is.

The basic APIs were there from the beginning in Windows 1.0, including multiple clipboard formats, application specific formats, and the ability to register for clipboard changes. More standard formats have been added over the years, but it still supports some ancient formats, like Software Arts' Data Interchange Format.

[+] pjc50|3 years ago|reply
> "inter-process communications"

Way back in the 90s, it was possible to put any (+) document inside any sufficiently aware app or document with OLE ("object linking and embedding")

The (+) indicates that there were a lot of terms and conditions applying to this, but you could actually just put an excel spreadsheet in a word document, and it would run a small copy of excel inside word. This is why the original word save format is so horrendous - it's serialized binary objects.

[+] Blikkentrekker|3 years ago|reply
What you describe also works on X11 and probably what MacOS uses too.

I'm not sure why it would be impressive or unusual. The ability to store arbitrary data on the clipboard with metadata that describes what data it is, such as an image file, or an audio file, is very old.

[+] lostsock|3 years ago|reply
I love how when you copy something onto the clipboard, it silently and transparently outputs different things depending on where you paste.

For example, copying from Excel can output:

- to a table (when copied into word)

- to rich text when copied into Wordpad

- to plain text when copied into Notepad

- and even an image when copied into Paint.

All without having to select the desired type at the source.

[+] analog31|3 years ago|reply
I believe Windows did a lot of things right by just keeping things simple for developers. I use the clipboard to transfer large blobs of data from one program to another when doing exploratory programming -- it's a lot quicker than creating file formats for everything. Of course there's the risk of losing it in the process.

Another under-appreciated Windows feature is how they implement drag-and-drop apps. When you drag a file into an app icon, it just stuffs the file path into the command line arguments and runs the app. In contrast, though MacOS introduced drag-and-drop, actually implementing it in System 7 was a huge complex chore.

[+] cecilpl2|3 years ago|reply
On Windows, it's now faster/easier to use the built in Snip+Sketch tool (Win + Shift + S).

It does instant rectangular selection, then pops up a simple editor which you can then copy/paste anywhere you'd like.

I have Win+Shift+S bound to a mouse chord, as well as copy and paste, so I can actually paste an arbitrary rectangle of my screen without touching the keyboard.

[+] SolarNet|3 years ago|reply
I do this exact same thing on linux without any issues. I use a presetup desktop environment, it's fine.

If I used arch or some other power user linux, I suspect I would have to jump through quite a few hoops to get this experience setup as nicely. But as someone who daily drives both a linux distribution and a windows distribution, I see no notable differences in clipboard functionality.

[+] yardshop|3 years ago|reply
Also really handy sometimes is Win+PrintScreen, which puts the screen image on the clipboard, and also saves it to a numbered file in your Pictures\Screenshots folder. If things are happening fast and you don't want to paste and manipulate each screen shot, this lets you save several in a row to go back and work with later.
[+] jjice|3 years ago|reply
For screenshots and edits, I have to say that I love MacOS's tools. CMD-Shift-4 to capture a screen region, click on it in the bottom right, edit it right there, and click 'Done'. Their editing tools are also super intuitive there. Honestly my favorite MacOS tool and I'd love a cross platform equivalent.
[+] pvg|3 years ago|reply
On the current macOS, the screenshot can be edited/annotated when it's previewed on the mac or on a nearby iPad where it automagically appears (with edits propagating back to the mac).

Something similar is available in the more modern Windows 'snipping tool' feature (win-shift-s) but without the tablet magic.

[+] cyral|3 years ago|reply
It's also great when you copy some text from Outlook and it pastes it into discord as an image of the text. I believe it has been fixed now but that was happening to me for a while.
[+] theandrewbailey|3 years ago|reply
The Old New Thing is such a treasure of insights into how Windows works (or used to work).
[+] ripley12|3 years ago|reply
It's interesting how The Old New Thing is clearly a passion project for Raymond, but it's also an essential part of Windows documentation. I've run into a lot of situations where Raymond's blog is way more useful than the official docs.
[+] EFruit|3 years ago|reply
Raymond's blog always hits a note of morbid fascination. At times it almost feels like schadenfreude. "Neat, but thank God I didn't have to be the one that wrote/discovered that."
[+] asciimov|3 years ago|reply
The Old New Thing and Dave's Garage (on youtube) have helped me develop an appreciation for the decisions made in Windows development, kinda wish we had this kind of stuff from the Mac and Linux side of things.
[+] Kipters|3 years ago|reply
I must admit, just by reading the title and the domain on HN's homepage I was dead sure it was a Raymond Chen post
[+] ErikAugust|3 years ago|reply
Wouldn’t it be nice if it threw an error, and didn’t just return NULL?
[+] jeffwask|3 years ago|reply
The world is run by one giant excel spreadsheet
[+] 867-5309|3 years ago|reply
I find the size always seems to run run parallel with my patience at that given moment
[+] capableweb|3 years ago|reply
> Next time, we’ll see what we can do to extend this timeout.

That, somehow, seems like the wrong conclusion. Why not try to solve the problem of Excel taking longer than 30 seconds to export a RTF table?

[+] kencausey|3 years ago|reply
Given the range of computers on which Excel is likely to be running that seems like a complete non-starter. There will always be cases that take longer than X no matter what you choose for X.
[+] seritools|3 years ago|reply
Cool, now it's optimized and it manages to export up to a million lines in 30 seconds. What do you propose to do when the next customer wants to copy 1.5 million lines?
[+] passivate|3 years ago|reply
I don't think its realistic to expect a Windows developer to solve a problem in Excel!
[+] nice_byte|3 years ago|reply
I'm actually quite surprised that it takes over 30 seconds to go through only 300000 items and generate some text with them. Unless the story is from ancient times, that is.
[+] dataflow|3 years ago|reply
> Next time, we’ll see what we can do to extend this timeout.

I guess I'm impatient... how does one go about this?

[+] jayd16|3 years ago|reply
tl;dr: Yes, but its measured in seconds.

wild.