What version of Sync Gateway are you running?
What version of Couchbase Server are you running?
Next time this happens, can you run sgcollect_info before the restart?
It’s difficult to determine why this happened with only the information in the post.
sgcollect_info will automatically zip up logs, heap profiles, stats, etc. to determine what is responsible for the memory usage.
Don’t post the zip publically. Send me a PM on the forums with the sgcollect_info zip.