Memory Issues with large syncs

Automate and integrate using the SQL comparison API

Moderator: Chris Auckland

Memory Issues with large syncs

Postby MarkLFT » Mon Feb 20, 2012 7:55 am

I am using the SDK in a Windows Service, to, based on a timer, sync two databases. The service runs fine but seems to suffer a memory leak. I have tracked this down to occasionally there is a large amount of data to sync. Infact the service memory in Windows grows from 50K to 1.2M. These rises are when the SDK is obtaining the difference.

Usually this memory is released after the sync, but as I said if it is a big sync, the memory is not full released.

I nothice in the sample code it mentions using GetFileStream() to avoid memory issues, but I am not sure how to use the resulting stream, as there is no execute method that takes a stream. Could someone give me an example of how to use the Stream option.

Many thanks
MarkLFT
 
Posts: 10
Joined: Fri Apr 22, 2011 3:59 am
Location: Bali, Indonesia

Postby Brian Donahue » Tue Feb 21, 2012 5:24 pm

Hello,

I don't think there is a way to make this synchronization any more efficient, and if the memory was not returned after use, that would be a memory leak. So there doesn't appear to be a memory leak because the memory is being freed.

Also, you have to be careful to look at the correct metric to determine the memory usage because the .net Framework will not always release memory back to the OS when it is done with it. Most times it keep the memory but marks it as free for use.

The GetFileStream method increases the efficiency of writing the synchronization script to disk only, and won't help you with the synchronization. For instance, if you wantes to write the script to disk without using GetFileStream, you would first have to turn the execution block to a string which will be completely in memory, and then writing that string to disk. Using a FileStream, you can read small bits (512 bytes) and write each buffer to disk instead.

If you have any more questions, please let us know.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am

Postby MarkLFT » Wed Feb 22, 2012 2:35 am

Thanks for the reply,but I believe a memory leak is exactly what I have.

If I run the service, but disable the SDK methods that perform the sync, the service always uses exactly the same amount of memory, and runs for extended periods of time with no problems.

However, if I leave the SDK methods in place, the service starts using about 3% of available system memory, within 24 hours that is up to 50%, with two to three days the system crashes as out of memory.

I would say that is the definition of a memory leak irrespective of which metric I use.

Thanks
MarkLFT
 
Posts: 10
Joined: Fri Apr 22, 2011 3:59 am
Location: Bali, Indonesia

Postby Brian Donahue » Thu Feb 23, 2012 5:47 pm

Please remember to call Dispose() on all disposable objects, or enclose your database, session, provider, and other disposable objects in a using block.
Brian Donahue
 
Posts: 6670
Joined: Mon Aug 23, 2004 10:48 am


Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests