Exception While Copying Huge Data To Clipboard

UiPath throws exception while copying huge data to clipboard .

Approach 1 ( UiPath Studio Versions < 21.10):
This issue is not with UiPath Application only, it is with all 32-bit applications. Applications call GlobalAlloc to allocate the memory for data to be stored on the clipboard and make it available to other applications.
For 32-bit applications GlobalAlloc can allocate blocks up to 2 GB in size or up to the amount of virtual memory the PC has, whichever is less. The Windows clipboard does not impose any other size limits.

A workaround which has worked with other customers is using data in chunks. You can use a counter with loops and append the data wherever you are saving it. It could be Excel, word, notepad etc. This is a recommended way when dealing with large amount of data.

It does not always clear the Clipboard, so it is a best practice to clear the Clipboard after Get Clipboard activity is performed in a loop.

Note: Use Clipboard class please do not forget to import namespace "System.Windows.Forms".

There can be many ways to clear clipboard, find below few of them

  • clear() : To use Clipboard.clear() method in UiPath; use it like below screenshot:

  • Set the clipboard text to empty using methods:
    SetText("")
    clipboard.PutInClipboard("")

  • Without using any predefined method Clipboard can we cleared by: Copy (Ctrl+c)->Get Clipboard -> Copy empty notepad, use this in loop. This will copy the black data which will clear existing data from Clip.




Approach 2 ( Versions >= 21.10)

Using 64bit application (UiPath.Executor in this case) have larger memory allocation than 32 bit UiPath.Executor so any memory issues can be overcome with UiPath Executor using 64bit version.

To Use 64bit Executor, follow below steps

  1. Create a UiPath Project with "Compatibility - Windows"

Create Project

  1. Create your process with Excel activities
  2. Once the processing is running, ensure the executor is running in 64 bit using Task Manager .

rjSQiTMmTw.png

1 Like