help-glpk
[Top][All Lists]
Advanced

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

Re: [Help-glpk] Gplk and exception handling


From: Heinrich Schuchardt
Subject: Re: [Help-glpk] Gplk and exception handling
Date: Wed, 19 Mar 2014 22:08:26 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131103 Icedove/17.0.10

Hello Sylvain,

this is the comment in src/env/env.c:

*  int glp_free_env(void);
*
*  DESCRIPTION
*
*  The routine glp_free_env frees all resources used by GLPK routines
*  (memory blocks, etc.) which are currently still in use.
*
*  Normally the application program does not need to call this routine,
*  because GLPK routines always free all unused resources. However, if
*  the application program even has deleted all problem objects, there
*  will be several memory blocks still allocated for the library needs.
*  For some reasons the application program may want GLPK to free this
*  memory, in which case it should call glp_free_env.
*
*  Note that a call to glp_free_env invalidates all problem objects as
*  if no GLPK routine were called.

On of the aforementioned memory blocks is the environment structure itself which is allocated in glp_init_env.

When a program completely ends all assigned memory is freed by the operating system.

Best regards

Heinrich Schuchardt


On 19.03.2014 13:52, Sylvain Fournier wrote:
Hi,

Thanks Heinrich, your comment helped me get rid of a memory leak I had
in my application: although it is done correctly in the examples
provided with GLPK for Java, I had forgotten to free the array memory
using the delete methods. I was only freeing the problem memory using
glp_delete_prob().
Now is it necessary to call glp_free_env() at the end of the program, or
does GLPK take care of it itself in the case it exits without any error?
You say that GC doesn't free the memory assigned in the GLPK library but
in the examples, I only saw the call to this method in one case using
several threads (GmplSwing). Why is it necessary in this case and not in
the other examples?

*Sylvain Fournier*




reply via email to

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