Hi,
Just happened to see that if memory is allocated in multiple chunks, then it is not free-ed properly chunk-by-chunk. Attached is a small patch which fixes the same. Also found that "runltp" is not capable of getting and then passing all parameters to ltp-full<>/tools/genload/stress.c. Need to work out ways by which user can mention "--vm-chunks","--vm-bytes","--vm-hang","--hdd-noclean" and "--hdd-files" too from command line while invoking "runltp".

Regards--
Subrata
--- ltp-full-20070630/tools/genload/stress.c.orig	2007-07-26 16:03:22.000000000 +0530
+++ ltp-full-20070630/tools/genload/stress.c	2007-07-26 15:51:22.000000000 +0530
@@ -692,7 +692,7 @@ hogvm (long long forks, long long chunks
 {
   long long i, j, k;
   int pid, retval = 0;
-  char *ptr;
+  char **ptr;
 
   /* Make local copies of global variables.  */
   int ignore = global_ignore;
@@ -720,12 +720,13 @@ hogvm (long long forks, long long chunks
 
           while (1)
             {
+              ptr = (char **) malloc ( chunks * 2);
               for (j = 0; chunks == 0 || j < chunks; j++)
                 {
-                  if ((ptr = (char *) malloc (bytes * sizeof (char))))
+                  if ((ptr[j] = (char *) malloc (bytes * sizeof (char))))
                     {
                       for (k = 0; k < bytes; k++)
-                        ptr[k] = 'Z';   /* Ensure that COW happens.  */
+                        ptr[j][k] = 'Z';   /* Ensure that COW happens.  */
                       dbg (stdout, "hogvm worker malloced %lli bytes\n", k);
                     }
                   else if (ignore)
@@ -752,7 +753,10 @@ hogvm (long long forks, long long chunks
                 {
                   dbg (stdout,
                        "hogvm worker freeing memory and starting over\n");
-                  free (ptr);
+                  for (j = 0; chunks == 0 || j < chunks; j++) {
+                      free (ptr[j]);
+                  }
+                  free(ptr);
                   continue;
                 }
 
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to