Giter Club home page Giter Club logo

Comments (2)

hobu avatar hobu commented on May 28, 2024
import rtree
import random
import time

def createDefaultIndex():
    idx = rtree.index.Rtree(u"defaultIndex")

    # make boxes....
    boxes = []
    for boxIndex in range(0,100):
        xmin = random.random()
        ymin = random.random()
        xmax = xmin + random.random()
        ymax = ymin + random.random()
        boxes.append((xmin,ymin,xmax,ymax))

    for boxIndex, box in enumerate(boxes):
        pickledObject = "makethisbig " * 100000
        idx.insert(boxIndex, box, obj=pickledObject)

    del idx

def readIndexDefault():
    indexPath = u"defaultIndex"
    #idx = rtree.index.Rtree(indexPath)
    idx = rtree.index.Index(indexPath)
    boundingCoords = [0,0,60,60]
    print "Consuming Index"
    startTime = time.time()
    #hits = list(idx.intersection(boundingCoords, objects=True)) # memory leak 
    #hits = list(idx.intersection(boundingCoords, objects="raw")) # no memory leak
    hits = list(idx.intersection(boundingCoords, objects=False)) # no memory leak
    #hits = list(idx.intersection(boundingCoords))
    endTime = time.time()
    print "Consuming time: ", endTime - startTime
    print "Hits: ", len(hits)
    time.sleep(10)

    print "Done Consuming - erasing memory"
    idx = None
    hits=None
    for counter in range(0,10):
        time.sleep(1)

# what we have learned: 
# if objects == true, we have memory leak. hits, idx each have
# the size of the dat file and those are released. however, there is
# a 3rd memory allocation for the size of the dat file, mysterious, that
# is not released.
# if object != true, then there is no memory leak.
# if object == "raw" then no memory leak

if name == "main":
    createDefaultIndex()
    readIndexDefault()

from rtree.

hobu avatar hobu commented on May 28, 2024

Can you please test this and reopen if it is still an issue?

from rtree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.