SQL Data Compare
Latest version: 10.0
Knowledge Base
Troubleshooting System.OutOfMemoryException during comparison
Category: Troubleshooting & error messages
Date: 16 Jul 2009
Product: SQL Data Compare
When comparing the data in certain databases, SQL Data Compare may stop with this error message:
System.OutOfMemoryException
This is not a software bug per se, but simply an indication that there is not enough storage available for the data comparison.
SQL Data Compare has been tested on extremely large databases (up terrabytes in size), and is very scalable. There are two situations where an out of memory situation can occur:
- There is not enough available temporary storage
====================================
SQL Data Compare make heavy use of caching to disk, by storing data in the %TMP% folder. This folder location is configurable, but is by default in your personal Windows profile folder, for instance "c:\documents and settings\username\temp". The %TMP% environment variable can be changed in the "My computer" area of your system, but we recommend setting a temporary file location specific to Red Gate SQL Tools by setting the %RGTEMP% environment variable in the current session.
For instance, if your system drive is low on space, you can use a different folder on a larger disk, in this example, by creating a folder called RGTEMP on drive D:
- Create the folder d:\rgtemp
- Open a command prompt
- Type "SET RGTEMP=d:\RGTEMP"
- Type the command to start Data Compare: "c:\program files\red gate\sql data compare 8\RedGate.SQLDataCompare.UI.exe"
- Run a comparison, note that files are appearing in d:\rgtemp
- Very large BLOBs are being compared
=============================
If your database makes heavy use of Binary Large Objects such as TEXT and IMAGE fields, each individual field from both databases needs to be loaded into memory at once. If these fields are large, you may exhaust your physical memory when trying to compare them. For instance, if you have got an individual BLOB column that is 1GB in size in one database and 1GB in the other database, 2GB of memory is needed to compare them. Unfortunately your only courses of action are to use a machine with more memory (a 64-bit machine may be needed to address more than 2GB of memory in a single process) or ignore these columns and synchronize them manually.
To detect all BLOB columns in a database, these queries are useful:
/ SQL 2005, 2008, Express /
SELECT o.[name] AS [Table Name],c.[name] AS [Column Name],
t.[name] AS [Column Type]
FROM sys.all_columns c
INNER JOIN sys.all_objects o
ON c.object_id = o.object_id
INNER JOIN sys.types t
ON c.system_type_id = t.system_type_id
WHERE c.system_type_id IN (35, 165, 99, 34, 173)
AND o.[name] NOT LIKE 'sys%'
AND o.[name] <> 'dtproperties'
AND o.[type] = 'U'
GO
/ SQL 2000 /
SELECT o.[name] AS [Table Name],c.[name] AS [Column Name],
t.[name] AS [Column Type]
FROM dbo.syscolumns c
INNER JOIN dbo.sysobjects o
ON c.id = o.id
INNER JOIN dbo.systypes t
ON c.xtype = t.xtype
WHERE c.xtype IN (35, 165, 99, 34, 173)
AND o.[name] NOT LIKE 'sys%'
AND o.[name] <> 'dtproperties'
AND o.xtype = 'U'
GO
Document ID: KB200810000312 Keywords: SQL,Data,OutOfMemoryException,OutOfMemory,RGTEMP
Was this article helpful?
SQL Data Compare
- Logging and log files
- Internal Connection Fatal Error in versions 4 and 5
- NULL textptr passed to UPDATETEXT function when running synchronization
- How much free hard disk space is required?
- Comparing the data of two tables in the same database
- Suggestions to combat comparison and synchronization performance issues
- SQL comparison and synchronization automation capabilities
- SqlNullValueException occurring in synchronization wizard
- SQL Data Compare command-line XML argument file examples
- Using Windows authentication logons between domains
- Using a filter on a column on related (joined) tables
- Determining minimum database permissions for SQL Data Compare
- Tables with compound keys may not be mapped automatically
- Best practices for synchronizing data
- Cleaning up a SQL script after SQL Compare or SQL Data Compare
- Troubleshooting System.OutOfMemoryException during comparison
- Exception thrown by db reader 1
- Reseed applying "incorrect" identity values
- Running migration scripts using SqlCmd.exe
- This SQL Server has been optimized for x concurrent queries.
- SQL Data Compare showing differences in 2 identical databases
- How to force SQL Compare and SQL Data Compare to use an Encrypted Connection
- Improving the performance of SQL Data Compare
- Logging and log files
- Case-sensitive comparisons
- Tables or views that could not be compared
all SQL products
- Compatibility of Red Gate tools in 64-bit environments
- Application has encountered an error and needs to close
- Error message after installing SQL Toolbelt - The description for Event ID ( 1 ) in Source ( nview_info ) cannot be found.
- Changing the temporary directory used by the installer
- Toolbelt Installer "hanging" while "scanning volumes"
- Login failing with "trusted SQL Server connection" error when using RunAs
all products
- Some Red Gate products identified as containing a trojan by Anti-Virus software
- Activation may fail with Unknown Error -1
- Product uses web help although a CHM file is available locally
- Argument exception resulting from missing environment variable
- Check for updates may fail when used through proxies
- 'Unidentified Publisher' error when repairing or uninstalling
- Licensing activates product as standard edition
- Moving Red Gate software products to another machine
- Red Gate tools log locations
- The application UI opening slowly when there is no internet access
SQL Data Compare
- Activating your products
- Activating your products
- Getting help offline
- Getting better performance out of SQL Data Compare
- Release notes - version 10.xx
- SQL Data Compare release notes - version 7.xx
- SQL Data Compare release notes - version 8xx
- SQL Data Compare release notes - version 9.xx
all SQL products
all products
- Red Gate product acknowledgements
- Activating your products
- Activating your products
- Red Gate bundle history
- Check for updates
- Troubleshooting Check for Updates errors
- Current versions
- Deactivating your products
- Installing Red Gate products from the .msi file
- Requesting additional activations
- Serial numbers for bundles
- Reactivating using a different serial number
- Extending your trial
- Finding your serial numbers
- Moving a serial number from one computer to another
- No response received for manual activation
- Licensing and activation resources
- Licensing and activation resources
- Troubleshooting licensing and activation errors
- Licensing and activation FAQs
- Red Gate tools log file locations
- Download old versions of products
- Download product prerequisites & utilities
- Support & upgrades
- Upgrading your software
- Upgrading FAQs

Using SQL Data Compare