patch 7.4.1727
Problem:    Cannot detect a crash in tests when caused by garbagecollect().
Solution:   Add garbagecollect_for_testing().  Do not free a job if is still
            useful.
diff --git a/src/testdir/runtest.vim b/src/testdir/runtest.vim
index 4d75af3..2b38981 100644
--- a/src/testdir/runtest.vim
+++ b/src/testdir/runtest.vim
@@ -60,6 +60,9 @@
 
 let s:srcdir = expand('%:p:h:h')
 
+" Prepare for calling garbagecollect_for_testing().
+let v:testing = 1
+
 " Support function: get the alloc ID by name.
 function GetAllocId(name)
   exe 'split ' . s:srcdir . '/alloc.h'
diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim
index e134527..05df50a 100644
--- a/src/testdir/test_channel.vim
+++ b/src/testdir/test_channel.vim
@@ -183,7 +183,7 @@
   call assert_equal('got it', s:responseMsg)
 
   " Collect garbage, tests that our handle isn't collected.
-  call garbagecollect()
+  call garbagecollect_for_testing()
 
   " check setting options (without testing the effect)
   call ch_setoptions(handle, {'callback': 's:NotUsed'})
@@ -1231,7 +1231,7 @@
   call assert_fails('call job_start("")', 'E474:')
 endfunc
 
-" This leaking memory.
+" This was leaking memory.
 func Test_partial_in_channel_cycle()
   let d = {}
   let d.a = function('string', [d])
@@ -1243,5 +1243,13 @@
   unlet d
 endfunc
 
+func Test_using_freed_memory()
+  let g:a = job_start(['ls'])
+  sleep 10m
+  call garbagecollect_for_testing()
+endfunc
+
+
+
 " Uncomment this to see what happens, output is in src/testdir/channellog.
 " call ch_logfile('channellog', 'w')