X

NV5 Geospatial Blog

Each month, NV5 Geospatial posts new blog content across a variety of categories. Browse our latest posts below to learn about important geospatial information or use the search bar to find a specific topic or author. Stay informed of the latest blog posts, events, and technologies by joining our email list!



Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

Monitor, Measure & Mitigate: Integrated Solutions for Geohazard Risk

9/8/2025

Geohazards such as slope instability, erosion, settlement, or seepage pose ongoing risks to critical infrastructure. Roads, railways, pipelines, and utility corridors are especially vulnerable to these natural and human-influenced processes, which can evolve silently until sudden failure occurs. Traditional ground surveys provide only periodic... Read More >

Geo Sessions 2025: Geospatial Vision Beyond the Map

Geo Sessions 2025: Geospatial Vision Beyond the Map

8/5/2025

Lidar, SAR, and Spectral: Geospatial Innovation on the Horizon Last year, Geo Sessions brought together over 5,300 registrants from 159 countries, with attendees representing education, government agencies, consulting, and top geospatial companies like Esri, NOAA, Airbus, Planet, and USGS. At this year's Geo Sessions, NV5 is... Read More >

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

Not All Supernovae Are Created Equal: Rethinking the Universe’s Measuring Tools

6/3/2025

Rethinking the Reliability of Type 1a Supernovae   How do astronomers measure the universe? It all starts with distance. From gauging the size of a galaxy to calculating how fast the universe is expanding, measuring cosmic distances is essential to understanding everything in the sky. For nearby stars, astronomers use... Read More >

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

Using LLMs To Research Remote Sensing Software: Helpful, but Incomplete

5/26/2025

Whether you’re new to remote sensing or a seasoned expert, there is no doubt that large language models (LLMs) like OpenAI’s ChatGPT or Google’s Gemini can be incredibly useful in many aspects of research. From exploring the electromagnetic spectrum to creating object detection models using the latest deep learning... Read More >

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

From Image to Insight: How GEOINT Automation Is Changing the Speed of Decision-Making

4/28/2025

When every second counts, the ability to process geospatial data rapidly and accurately isn’t just helpful, it’s critical. Geospatial Intelligence (GEOINT) has always played a pivotal role in defense, security, and disaster response. But in high-tempo operations, traditional workflows are no longer fast enough. Analysts are... Read More >

1345678910Last
«September 2025»
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
10922 Rate this article:
No rating

What the *bleep* is IDL doing? Garbage collection

Anonym

In 8.0, automatic garbage collection was introduced to the IDL language. What it brought was some much needed relief in controlling the memory used by IDL.  Pre IDL 8.0, if you ran:

obj = obj_new('MyIDLObject')

obj = obj_new('MyOtherIDLObject')

Then the first instance of obj was "leaked", meaning the memory could no longer be accessed by IDL and would be inaccessible until IDL was restarted. This is especially bad in large applications where "leaked" memory would slowly consume all the resources of the machine. With the addition of garbage collection, as soon as the second call happens, the first object is freed and the memory it used is released back to IDL. So in IDL 8.4:

IDL> o = obj_new('MyIDLObject') & help,/heap,/brief

Heap Variables:

    # Pointer: 0

    # Object : 1

    # Bytes Heap Memory:  24

IDL> o = obj_new('MyOtherIDLObject') & help,/heap,/brief

Heap Variables:

    # Pointer: 0

    # Object : 1

    # Bytes Heap Memory:  24

However, consider the following example:

        p = plot(/test)

        p = plot(randomu(seed,100))

If you run these statements, both plot windows will stay open even though it seems like IDL's garbage collection should have freed the first instance of p. The reason IDL doesn't free the first instance of p is because of something called reference counting. In order to perform garbage collection, IDL needs to know when the user can no longer reference an object. So if you run:

a = obj_new('MyIDLObject')

b =  a

help,/heap

IDL prints:

Heap Variables:

    # Pointer: 0

    # Object : 1

<ObjHeapVar2>  refcount=2

                STRUCT    = -> MYIDLOBJECT Array[1]

 

The refcount field tells you how many IDL variables are pointing to the same object.  As soon as the refcount becomes 0, IDL's garbage collection will free the object.

Side Note: Be very careful using the OBJ_DESTROY method.  If I call OBJ_DESTROY on b, a will no longer be a valid object.  If you want to free an unnecessary reference to an object, set the variable to either !NULL or 0 to avoid destroying the object for all other references.

Let's get back to the PLOT example. In this case, IDL is holding the refcount above zero since the window is still open. Until you close the window, the plot will stay alive. You may be asking yourself, "well if IDL has the window, how do I get a reference back to it because I really didn't mean to lose my previous reference". Here is where GETWINDOWS() and WINDOW(/current) shine. Let's say you ran the following code:

p = plot(/test)

p = plot(randomu(seed,100))

Oops, we didn't want to lose a reference to the first plot object!  To get that reference back: first, click on the window then run:

w = WINDOW(/current)

Then select the plot inside the window and run:

p1 = w.getselect()

help, p1

P1         PLOT <5168>

The first line snags a reference of the active window. The second line grabs a reference to the plot. Similarly, you can grab a reference to the plot without having to click anything by using GETWINDOWS():

pwin = GETWINDOWS()

Will return an array of references to all active plot windows in the order they were created. By indexing into the desired window, we can grab a reference to the plot by:

tool = pwin[0].gettool()

id = igetid('plot',tool=tool)

obj = tool->getbyidentifier(id)

obj->idlitcomponent::getproperty, _proxy=p1

help, p1

P1         PLOT <5168>

By understanding the lifecycle of IDL objects, you can better manage the memory IDL uses as well as retrieve objects you might have thought were lost.

Please login or register to post comments.