help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] glpk - memory problem


From: Andrew Makhorin
Subject: Re: [Help-glpk] glpk - memory problem
Date: Mon, 10 Apr 2006 22:15:43 +0400

Hi Andrea,

> in the attached file you can see the function "lp_Solving", which
> serves 
> as a wrapper function for lp queries.
> When I invoke this function for several times ( upto >1000
> times), the 
> computer runs out of memory (upto 2GB RAM).
> Only the invocation of the function "lib_free_env()" in line 174
> solves 
> these memory problems, as the memory consumption drops down to
> 40MB.

Quickly looking at your code I didn't detect anything unusual
except two points:

1) lpx_scale_prob() should be called *after* lpx_load_mat(), because
   the scaling routine uses values of constraint coefficients;

2) you must not call free(lp), because lpx_free_prob(lp) destroys
   the problem object which lp points to, i.e. lp passed to free() is
   invalid and attempt to free the corresponding memory block may
   cause addressing error or even unpredictable errors later.

Remove the call to lib_free_env() and add the following fragment to
your code before return to the calling program:

   printf("total = %d; count = %d\n",
      lib_env_ptr()->mem_total, lib_env_ptr()->mem_count);

mem_total is a total amount of memory (in bytes) which is still
allocated by glpk routines via umalloc/ucalloc, and mem_count is the
number of memory blocks which are still allocated.

This fragment must always prints zeros meaning that all the memory
allocated by glpk routines has been deallocated via ufree. If you
will see non-zeros, please report to me.


Andrew Makhorin





reply via email to

[Prev in Thread] Current Thread [Next in Thread]