Opened 12 years ago

Closed 11 years ago

#1833 closed defect (fixed)

R_command_history() memory leak

Reported by: jniesterowicz Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: LibRaster Version: svn-trunk
Keywords: history Cc:
CPU: Unspecified Platform: Linux

Description

Hello,

Function Rast_command_history() causes a memory leak of 1024 bytes + the size of command line.

1024 bytes are allocated in Rast_recreate_command() and is no freed later. The rest of the leak comes from Rast_append_history(). This memory is not freed later as well.

Jacek

Change History (2)

in reply to:  description comment:1 by glynn, 12 years ago

Replying to jniesterowicz:

Function Rast_command_history() causes a memory leak of 1024 bytes + the size of command line.

1024 bytes are allocated in Rast_recreate_command() and is no freed later.

Fixed in r54265.

The rest of the leak comes from Rast_append_history(). This memory is not freed later as well.

It's freed by calling Rast_free_history() once you no longer need the history (which is typically after it has been written). Most modules write the history shortly before terminating, so there's seldom any reason to explicitly free the memory.

I suppose that this could theoretically be an issue for modules which create an arbitrary number of output maps. In practice, it's irrelevant, although specific cases (i.e. modules which use O(n) storage for history when they could reasonably use O(1) storage) will probably be dealt with as they are reported.

comment:2 by neteler, 11 years ago

Resolution: fixed
Status: newclosed

Closing since the leak has been fixed.

Note: See TracTickets for help on using tickets.