PROBLEM sql server management studio 2008 sucks up with memory yielding a .net runtime error. It crashes with an empty message in an error-dialog but there can be found a little eventlog entry, reading:
<EventData>
<Data>.NET Runtime version 2.0.50727.5446 - Fatal error in the execution engine (7269AECA) (0).</Data>
</EventData>
Original Eventlog Entry (German):
<EventData>
<Data>.NET Runtime version 2.0.50727.5446 - Schwerwiegender Fehler im Ausführungsmodul (7269AECA) (0).</Data>
</EventData>
RECREATING THE ERROR
After about every 10 Million-th Insert-Statement Management Studio 2008 executed in a loop against a remote instance of SQL Server 2005, the 4GB of memory on my dev-workstation are up which leads to the stated error above. Why the hell i'm executing insert-statements in a loop? - Since SQL Server doesn't allow one to set the actual TIMESTAMP of a DB manually, dummy-data-manipulation-statements are needed to help one out (the TIMESTAMP-manipulation-lock is no bad idea but on a dev-environment sometimes needed).
CREATE TABLE __DUMMY (I INT, TS TIMESTAMP)
DECLARE @FROM INT
DECLARE @TO INT
SET @FROM = 666
SET @TO = 666666666
WHILE (@FROM < @TO)
BEGIN
INSERT INTO __DUMMY (I) VALUES(@FROM)
SET @FROM = @FROM +1
END
On another session to SQL Server I truncate the __DUMMY-table from time to time:
SELECT @@DBTS, CONVERT(INT, @@DBTS), 'SERVER'
UNION
SELECT CONVERT(TIMESTAMP, 666666666), 666666666, 'CLIENT'
EXEC sp_spaceused '__DUMMY'
TRUNCATE TABLE __DUMMY
--writes ~10.000 Tuple/Second
--allocates ~100.000 Byte/10.000 Tuple
-- ==> ~10 Byte/Tuple (are "roughly" made up of: INT = 4 BYTE, TIMESTAMP = 8 BYTE)
--insert/truncate is ~100.000 times more performant than doing a insert/delete in the loop or a permanent update on one tuple (haven't tried indices yet)
See http://www.flickr.com/photos/74806161@N03/6732847259/in/photostream for image showing sucker-process-descriptions and http://www.flickr.com/photos/74806161@N03/6732846981/in/photostream for image showing the memoryconsumption of the sucker-process
Anyone any Ideas?
@@DBTS
gets up to some target value? Why does it matter to you what specific value these have? In any event don't do this as single row inserts. set based inserts will be massively quicker. I presume it is the accumulation of the "1 row(s) affected" messages that is crashing SSMS