Python 3.3 urllib memory leakage

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • formel
    New Member
    • Apr 2014
    • 2

    Python 3.3 urllib memory leakage

    Im using mac mini with ios 10.9.2 and Python 3.3. I wrote simple Python app, which fetch api data and shows some calculation. Everything is working well, but i saw in Activity Monitor (os tool) that after few connections system memory usage incrases, but in my opinion it shouldnt. I wouldnt publish aplication that can eat all memory so I need a help.

    Here is a pice of my code which makes this problem:

    Code:
    import urllib.request
    import time
    
    class Main(object):
        def Get(self, url):
            urlData = urllib.request.urlopen(url)
            for line in urlData:
                line = str(line,'utf-8')
                print( line.rstrip() )
            urlData.close()
            time.sleep(1)
    
    M = Main()
    url = "https://btc-e.com/api/2/btc_usd/trades"
    b=1
    
    while b>0:
        M.Get(url)
    I tried to do in another way but it makes memory usage incrasing too:

    Code:
    req = request.urlopen('https://btc-e.com/api/2/btc_usd/trades')
    urlData = json.loads(req.read().decode('utf-8'))
    This makes memory usage higher too:

    Code:
    from urllib.request import urlopen
    html = urlopen("https://btc-e.com/api/2/btc_usd/trades")
    Thank you in advance!
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    This question is better asked on a Mac forum where people know more about the OS than us. The short answer is it depends on which program you are using to display memory usage. Does it display real usage or shared memory usage. Also, the Mac OS is related to Linux in some way, and Linux allocates all the memory that a program might ever use, when the memory is available, and so some tools would report a lot of memory "used" even though that memory is just waiting there and is available for other programs.

    Comment

    • formel
      New Member
      • Apr 2014
      • 2

      #3
      Thank You for answer.

      I will check memory usage with other tool.
      Is there any python 3.3 tool to check if memory was relased?

      Comment

      Working...