473,549 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python 3.3 urllib memory leakage

2 New Member
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:

Expand|Select|Wrap|Line Numbers
  1. import urllib.request
  2. import time
  3.  
  4. class Main(object):
  5.     def Get(self, url):
  6.         urlData = urllib.request.urlopen(url)
  7.         for line in urlData:
  8.             line = str(line,'utf-8')
  9.             print( line.rstrip() )
  10.         urlData.close()
  11.         time.sleep(1)
  12.  
  13. M = Main()
  14. url = "https://btc-e.com/api/2/btc_usd/trades"
  15. b=1
  16.  
  17. while b>0:
  18.     M.Get(url)
  19.  
I tried to do in another way but it makes memory usage incrasing too:

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

Expand|Select|Wrap|Line Numbers
  1. from urllib.request import urlopen
  2. html = urlopen("https://btc-e.com/api/2/btc_usd/trades")
Thank you in advance!
Apr 17 '14 #1
2 2475
dwblas
626 Recognized Expert Contributor
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.
Apr 17 '14 #2
formel
2 New Member
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?
Apr 18 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3725
by: frustrated | last post by:
Before I begin, I must first make the following disclaimer: Although I have considerable programming experience, I do not consider myself by any means to be an expert C++ programmer. The following may be nothing more than a relection of my ignorance. If what I describe is not an actual bug, I would be very appreciative if you could briefly...
0
1788
by: boy | last post by:
Hi all, I have created a simple template class as follow, but i encountered memory leakage on the base.Render(writer). Have all you of encountered the same problem? using System; using System.Web.UI; public class PageBase : System.Web.UI.Page {
7
1769
by: andylcx | last post by:
hi all: I have a code like below, is there any serious memory leakage in my code. I am confusion now but no idea how to fix it. In the member function of class A, I create a new object of class B like below: void A::function() { B *newobject = new B; newobject->....; newobject->....; //did some action here
18
2246
by: Ramasubbu Ramasubramanian XR (AS/EAB) | last post by:
What is memory leakage, could any one explain with sample code
1
3783
by: Gaël | last post by:
Hi everybody! I have a really big problem with ASP.NET application. I noticed that the w3wp.exe memory size, increase with the time and the use of my website. When it raise a certain value, w3wp crashes and restart just after. My application is on a WebServer2003. So I have to resolve 2 problem : -Why the memory size of the w3wp increase...
2
1389
by: chets | last post by:
Hi all Can anyone tell me what is the difference between:- *p=q; and p=&q; in C where declaration is like this char **p; char *q; Because if I do *p=q; in one file after mallocing q and want to free q
0
1353
by: kiran kumar | last post by:
Hi All, I am working on embedded python on C these days. I feel there is a memory leakage in this code. I have used our own memory pool and all the python code will use the heap from this memory pool. RunScript(pScriptName,pFuncName,...) { PyEval_AcquireLock() threadState = Py_NewInterpreter(); PyThreadState_Swap(threadState);
14
2324
by: madhawi | last post by:
i want to know that on what situation memory leakage happan and what is the solution to solve the problem of memory leakage.
11
2278
by: prpradip | last post by:
I have an ImageList (_imageList). In _imageList I have put large numbers of Icons. Now what I need is to get Handle of all Icons that I put in _imageList, so that I can destroy (DestoryIcon) them all and release the memory because it's causing Memory leakage.
0
7521
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7451
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7959
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7810
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5369
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3501
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3483
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1944
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1061
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.