Thanks Jordi, For RAM usage on Windows I simply check how much is used by the python.exe process using the Task Manager.
Reusing the application makes sense. The other solution I've found is to put the segmentation in a process (from 'multiprocessing'). When the process ends, the otbApplication is destroyed as far as I can tell. On May 7, 2014 11:31 PM, "Jordi Inglada" <[email protected]> wrote: > Anders Knudby <[email protected]> wrote: > > > > Hi all, I'm working on some code like what's in the cookbook examples > (e.g. http://www.orfeo-toolbox.org/CookBook/CookBooksu108.html). It looks > like this at the moment: > > > > Segmentation = > otbApplication.Registry.CreateApplication("Segmentation") > > > > # The following lines set all the application parameters: > > Segmentation.SetParameterString("in", compositeFileName) > > Segmentation.SetParameterString("mode.raster.out", > rasterSegmentsFileName) > > Segmentation.SetParameterString("filter","meanshift") > > Segmentation.SetParameterString("mode","raster") > > > Segmentation.SetParameterInt("filter.meanshift.spatialr",spatial_radius) > > > Segmentation.SetParameterFloat("filter.meanshift.ranger",range_radius) > > Segmentation.SetParameterFloat("filter.meanshift.thres",threshold) > > > Segmentation.SetParameterInt("filter.meanshift.maxiter",max_iterations) > > Segmentation.SetParameterInt("filter.meanshift.minsize",min_size) > > Segmentation.SetParameterOutputImagePixelType("mode.raster.out", 3) > > > > # The following line executes the application > > Segmentation.ExecuteAndWriteOutput() > > > > With the image I'm working on, the memory consumed by the Python process > is ~40MB before I run this piece of code, and ~550MB after. All the memory > is taken up when the first line, which > > creates the otbApplication, is run. I'm looking for a good way to free > up the memory after the last line, which write the desired result to file. > I've searched for something like > > otbApplication.Registry.DestroyApplication(), but that doesn't exist. > I've tried Segmentation = None, doesn't work either. > > > > Any ideas? Anything in the cookbook? (If not, probably worth putting > something in there) > > I think this is more a Python problem than an OTB one. Even if you set > Segmentation = None, I suppose that Python's garbage collector will not > free up memory until it really needs it. > > What I usually do in my scripts is reusing the same application instead of > instanciating new ones. That is, if you perform several segmentations, you > can re-use the same application by just changing the parameters and > re-executing. > > One last thing: I don't know how you how are you measuring RAM useage, but > if you are using linux, check the section "Why does top and free say all my > ram is used if it isn't?" in http://www.linuxatemyram.com/. > > Cheers, > > Jordi > > -- > -- > Check the OTB FAQ at > http://www.orfeo-toolbox.org/FAQ.html > > You received this message because you are subscribed to the Google > Groups "otb-users" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/otb-users?hl=en > --- > You received this message because you are subscribed to a topic in the > Google Groups "otb-users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/otb-users/edaoS4G8wv4/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- -- Check the OTB FAQ at http://www.orfeo-toolbox.org/FAQ.html You received this message because you are subscribed to the Google Groups "otb-users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/otb-users?hl=en --- You received this message because you are subscribed to the Google Groups "otb-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
