Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.basic/test/if.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.basic/test/if.sh	(revision 40771)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.basic/test/if.sh	(revision 40772)
@@ -320,2 +320,82 @@
  end
 end
+
+# check memleaks
+macro memtest1
+
+ local a b i N
+
+ $i = 0
+ $a = 1
+
+ memory check
+ output /dev/null 
+ for i 0 1000
+   if ($a == 1)
+    echo "run"    
+   end
+ end    
+ output stdout
+ memory check
+end
+
+# check memleaks
+macro memtest2
+
+ local a b i N
+
+ $i = 0
+ $a = 1
+ $b = 2
+
+ memory check
+ output /dev/null
+ for i 0 1000
+   if (($a == 1) && ($b == 2))
+    echo "run"    
+   end
+ end    
+ output stdout
+ memory check
+end
+
+# memory test using continue
+macro memtest3
+
+ local a b i N
+
+ $i = 0
+ $a = 1
+ $b = 2
+
+ memory check
+ output /dev/null
+ for i 0 1000
+   if (($a == 1) && ($b == 2))
+    continue
+    echo "run"    
+   end
+ end    
+ output stdout
+ memory check
+end
+
+# memory test using continue
+macro memtest4
+
+ local a b i N bool
+
+
+ $i = 0
+ $a = 1
+ $b = 2
+ $bool = 0
+
+ memory check
+ output /dev/null
+ for i 0 1000
+   $bool = (($a == 1) && ($b == 2))
+ end    
+ output stdout
+ memory check
+end
Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.basic/test/macro.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.basic/test/macro.sh	(revision 40771)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.basic/test/macro.sh	(revision 40772)
@@ -7,4 +7,13 @@
 # Is the macro working?
 macro test_prep
+ $test_var1 = check1
+ $test_var2 = check2
+ $var_count = $0
+end
+
+# Is the macro working?
+macro test_local
+ local test_var test_var2 var_count
+
  $test_var1 = check1
  $test_var2 = check2
@@ -47,2 +56,30 @@
  end
 end
+
+# Memory Test for macro
+macro memtest2
+
+ $i = 0
+ test_prep
+
+ memory check
+ for i 0 10000
+  test_prep
+ end    
+ memory check
+  
+end
+
+# Memory Test for macro
+macro memtest3
+
+ $i = 0
+ test_local
+
+ memory check
+ for i 0 10000
+  test_local
+ end    
+ memory check
+  
+end
Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/cut.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/cut.sh	(revision 40771)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/cut.sh	(revision 40772)
@@ -37,2 +37,42 @@
  end
 end
+
+macro memtest1
+
+ $i = 0
+ mcreate tim 100 100
+ cut tim xdir imx X 40 4 60 6
+ # do one to set up memory that should stay used
+
+ memory check
+ for i 0 100
+   cut tim xdir imx X 40 4 60 6
+ end
+ memory check
+   
+ for i 0 100
+   cut tim xdir imx y 40 4 60 6
+ end
+ memory check
+   
+ for i 0 100
+   cut -median tim xdir imx X 40 4 60 6
+ end
+ memory check
+   
+ for i 0 100
+   cut -median tim xdir imx y 40 4 60 6
+ end
+ memory check
+   
+ for i 0 100
+   cut -mean tim xdir imx X 40 4 60 6
+ end
+ memory check
+   
+ for i 0 100
+   cut -mean tim xdir imx y 40 4 60 6
+ end
+ memory check
+   
+end
Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/set.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/set.sh	(revision 40772)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/set.sh	(revision 40772)
@@ -0,0 +1,43 @@
+
+macro memtest1
+
+ create x -10 10 0.1
+ set y = zero(x)
+ $i = 0
+
+ memory check
+ for i 0 1000
+   set y = exp(x)
+ end
+ memory check
+   
+end
+
+macro memtest2
+
+ create x -10 10 0.1
+ set y = zero(x)
+ $i = 0
+
+ memory check
+ for i 0 1000
+   set y = (x < 0) ? x : exp(x)
+ end
+ memory check
+   
+end
+
+macro memtest3
+
+ create x -10 10 0.1
+ set y = zero(x)
+ $i = 0
+
+ memory check
+ for i 0 1000
+   set y = (x < 5 + 2*$i) ? x : exp(x)
+ end
+ memory check
+   
+end
+
Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/vsigmoid.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/vsigmoid.sh	(revision 40771)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/vsigmoid.sh	(revision 40772)
@@ -217,2 +217,47 @@
  end
 end
+
+macro memtest1
+
+ create x -10 10 0.1
+ set y = 0 + 5 / (1 + exp((x - 3)/4))
+
+ $C0 = 1
+ $C1 = 2
+ $C2 = 10
+ $C3 = 1
+ set dy = sqrt(y)
+ set yfit = zero(y)
+
+ $i = 0
+
+ memory check
+ for i 0 1000
+   vsigmoid -q x y dy yfit
+ end
+ memory check
+   
+end
+
+macro memtest2
+
+ create x -10 10 0.1
+ set y = 0 + 5 / (1 + exp((x - 3)/4))
+
+ $C0 = 1
+ $C1 = 2
+ $C2 = 10
+ $C3 = 1
+ set dy = sqrt(y)
+ set yfit = zero(y)
+
+ $i = 0
+
+ memory check
+ for i 0 1000
+   vsigmoid -q -r x y dy yfit
+ end
+ memory check
+   
+end
+
Index: /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/vstat.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/vstat.sh	(revision 40772)
+++ /branches/eam_branches/ohana.20190329/src/opihi/cmd.data/test/vstat.sh	(revision 40772)
@@ -0,0 +1,28 @@
+
+macro memtest1
+
+ # preset variables so memory usage does not change
+ $PMIN = -10
+ $PMAX = 9.9
+ $MIN = -10
+ $MAX = 9.9
+ $MEDIAN = -0.1097
+ $MEAN = -0.05
+ $MODE = -10
+ $TOTAL = -10
+ $NPIX = 200
+ $NPTS = 200
+ $NUSED = 200
+ $SIGMA = 5.7879184514
+
+ create x -10 10 0.1
+ $i = 0
+
+ memory check
+ for i 0 1000
+   vstat -q x
+ end
+ memory check
+   
+end
+
Index: /branches/eam_branches/ohana.20190329/src/opihi/mana/deimos_mkobj.c
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/mana/deimos_mkobj.c	(revision 40771)
+++ /branches/eam_branches/ohana.20190329/src/opihi/mana/deimos_mkobj.c	(revision 40772)
@@ -86,4 +86,10 @@
     Nwave = atoi (argv[N]);
     remove_argument (N, &argc, argv);
+  }
+
+  int VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    remove_argument (N, &argc, argv);
+    VERBOSE = TRUE;
   }
 
@@ -200,5 +206,5 @@
       dxr = 1 - dxf;
       Npof += dxi;
-      if (iy % 200 == 0) { fprintf (stderr, "%d : %f : %d : %f %f\n", iy, dx, dxi, dxf, dxr); }
+      if (VERBOSE && (iy % 200 == 0)) { gprint (GP_ERR, "%d : %f : %d : %f %f\n", iy, dx, dxi, dxf, dxr); }
     }
 
Index: /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_fitprofile.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_fitprofile.sh	(revision 40772)
+++ /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_fitprofile.sh	(revision 40772)
@@ -0,0 +1,28 @@
+
+macro memtest1
+  # generate slit profile:
+  create xprof 0 17
+  $Xpmin = 3
+  $Xpmax = 13
+  set profile_left  = (xprof <= $Xpmin) ? exp(-0.5*(xprof - $Xpmin)^2/1.0^2) : zero(xprof)
+  set profile_right = (xprof >= $Xpmax) ? exp(-0.5*(xprof - $Xpmax)^2/1.0^2) : zero(xprof)
+  set profile_mid   = (xprof > $Xpmin) && (xprof < $Xpmax) ? zero(xprof) + 1 : zero(xprof)
+  set fprofile = profile_left + profile_mid + profile_right
+  set wprofile = 0.02*fprofile
+
+  $i = 0
+  deimos fitprofile -q xprof fprofile wprofile $Xpmin $Xpmax
+
+  # tv -n 0 out 250 750
+  # center 15 50 20
+  # resize 850 2050
+  # tvcolor rainbow
+  # break
+
+  memory check
+  for i 0 1000  
+    deimos fitprofile -q xprof fprofile wprofile $Xpmin $Xpmax
+  end
+  memory check
+end
+
Index: /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_fitslit.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_fitslit.sh	(revision 40772)
+++ /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_fitslit.sh	(revision 40772)
@@ -0,0 +1,31 @@
+
+macro memtest1
+  # make a delta-function profile
+  create x 0 11
+  set yg = exp(-0.25*(x - 5)^2)
+
+  # flux vs wavelength is flat & short 
+  create w 0 100
+  set f = zero(w) + 1
+
+  delete -q Xn Yn
+  vlist Xn   0 100
+  vlist Yn   0   2
+
+  spline create trace Xn Yn
+  spline apply  trace w  dX
+  $i = 0
+
+  # run once to ensure the output is create
+  deimos mkslit yg trace trace outbuff -flux f
+  mgaussdev noise outbuff[][0] outbuff[0][] 0.0 0.2
+
+  set obs = 2*outbuff + noise
+  deimos fitslit obs outbuff outf outs
+
+  memory check
+  for i 0 1000  
+    deimos mkslit yg trace trace outbuff -flux f
+  end
+  memory check
+end
Index: /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkalt.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkalt.sh	(revision 40772)
+++ /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkalt.sh	(revision 40772)
@@ -0,0 +1,55 @@
+
+macro memtest1
+  # generate LSF:
+  create x 0 7
+  set lsf = exp(-0.5*(x-3)^2)
+
+  # generate PSF:
+  create xp 0 9
+  set psf = exp(-0.5*(xp-5)^2/1.5^2)
+
+  # generate slit profile:
+  create xprof 0 17
+  $Xpmin = 3
+  $Xpmax = 13
+  set profile_left  = (xprof <= $Xpmin) ? exp(-0.5*(xprof - $Xpmin)^2/1.0^2) : zero(xprof)
+  set profile_right = (xprof >= $Xpmax) ? exp(-0.5*(xprof - $Xpmax)^2/1.0^2) : zero(xprof)
+  set profile_mid   = (xprof > $Xpmin) && (xprof < $Xpmax) ? zero(xprof) + 1 : zero(xprof)
+  set profile = profile_left + profile_mid + profile_right
+
+  # generate object flux:
+  create wave 0 100
+  set flux = 100 + 0.5*wave
+
+  # generate sky flux:
+  set sky = 200 + zero(wave)
+
+  # off-slit background:
+  set backgnd = 300 + zero(wave)
+
+  # slit trace
+  vlist Xn   0 100 
+  vlist Yn   0   4
+  spline create slit_trace_in Xn Yn
+
+  # psf trace
+  vlist Xn   0 25 50 75 100 
+  vlist Yn   0  2  4  2   0
+  spline create psf_trace_in Xn Yn
+
+  $i = 0
+  deimos mkalt out 31 -psf psf -object flux -sky sky -stilt 20.0 -profile profile -backgnd backgnd -trace slit_trace_in
+
+  # tv -n 0 out 250 750
+  # center 15 50 20
+  # resize 850 2050
+  # tvcolor rainbow
+  # break
+
+  memory check
+  for i 0 1000  
+    deimos mkalt out 31 -psf psf -object flux -sky sky -stilt 20.0 -profile profile -backgnd backgnd -trace slit_trace_in
+  end
+  memory check
+end
+
Index: /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkobj.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkobj.sh	(revision 40772)
+++ /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkobj.sh	(revision 40772)
@@ -0,0 +1,55 @@
+
+macro memtest1
+  # generate LSF:
+  create x 0 7
+  set lsf = exp(-0.5*(x-3)^2)
+
+  # generate PSF:
+  create xp 0 9
+  set psf = exp(-0.5*(xp-5)^2/1.5^2)
+
+  # generate slit profile:
+  create xprof 0 17
+  $Xpmin = 3
+  $Xpmax = 13
+  set profile_left  = (xprof <= $Xpmin) ? exp(-0.5*(xprof - $Xpmin)^2/1.0^2) : zero(xprof)
+  set profile_right = (xprof >= $Xpmax) ? exp(-0.5*(xprof - $Xpmax)^2/1.0^2) : zero(xprof)
+  set profile_mid   = (xprof > $Xpmin) && (xprof < $Xpmax) ? zero(xprof) + 1 : zero(xprof)
+  set profile = profile_left + profile_mid + profile_right
+
+  # generate object flux:
+  create wave 0 100
+  set flux = 100 + 0.5*wave
+
+  # generate sky flux:
+  set sky = 200 + zero(wave)
+
+  # off-slit background:
+  set backgnd = 300 + zero(wave)
+
+  # slit trace
+  vlist Xn   0 100 
+  vlist Yn   0   4
+  spline create slit_trace_in Xn Yn
+
+  # psf trace
+  vlist Xn   0 25 50 75 100 
+  vlist Yn   0  2  4  2   0
+  spline create psf_trace_in Xn Yn
+
+  $i = 0
+  deimos mkobj out 31 -psf psf -object flux -sky sky -stilt 20.0 -lsf lsf -profile profile -backgnd backgnd -slit-trace slit_trace_in -psf-trace psf_trace_in
+
+  # tv -n 0 out 250 750
+  # center 15 50 20
+  # resize 850 2050
+  # tvcolor rainbow
+  # break
+
+  memory check
+  for i 0 1000  
+    deimos mkobj out 31 -psf psf -object flux -sky sky -stilt 20.0 -lsf lsf -profile profile -backgnd backgnd -slit-trace slit_trace_in -psf-trace psf_trace_in
+  end
+  memory check
+end
+
Index: /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkslit.sh
===================================================================
--- /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkslit.sh	(revision 40772)
+++ /branches/eam_branches/ohana.20190329/src/opihi/mana/test/deimos_mkslit.sh	(revision 40772)
@@ -0,0 +1,28 @@
+
+
+macro memtest1
+  # make a delta-function profile
+  create x 0 11
+  set yg = exp(-0.25*(x - 5)^2)
+
+  # flux vs wavelength is flat & short 
+  create w 0 100
+  set f = zero(w) + 1
+
+  delete -q Xn Yn
+  vlist Xn   0 100
+  vlist Yn   0   2
+
+  spline create trace Xn Yn
+  spline apply  trace w  dX
+  $i = 0
+
+  # run once to ensure the output is create
+  deimos mkslit yg trace trace outbuff -flux f
+
+  memory check
+  for i 0 1000  
+    deimos mkslit yg trace trace outbuff -flux f
+  end
+  memory check
+end
