python memory leak only in x86 64 linux
rkmr.em at gmail.com
rkmr.em at gmail.com
Wed Apr 16 12:10:42 EDT 2008
This is the code that is causing memory leak in 64 bit python [but not
in 32 bit python].. is something wrong in the code?
now = datetime.datetime.now()
oneday = datetime.timedelta(days=1)
def birthdaycompare(a, b):
if a is None and b:
return 1
if a and b is None:
return -1
if a is None and b is None:
return 0
if a<b:
return -1
elif a==b:
return 0
else:
return 1
def compare_by(fieldname):
def comparedict(a,b):
return birthdaycompare(a[fieldname], b[fieldname])
return comparedict
def getbirthdays(friend_details):
new_f = []
birthday = None
birthday_dt = None
for f in friend_details:
if f.has_key('birthday'):
birthday = f['birthday']
if birthday and birthday !='':
birthday_split = birthday.split(',')[0]
if birthday_split == 'February 29':
birthday = 'February 28'
try:
birthday_dt =
datetime.datetime.strptime(birthday_split + ', ' + str(now.year) , '%B %d, %Y')
if birthday_dt < (now - oneday):
birthday_dt =
datetime.datetime.strptime(birthday_split + ', ' + str(now.year+1) ,
'%B %d, %Y')
except:
birthday=None
birthday_dt=None
f['birthday'] = birthday
f['birthday_dt'] = birthday_dt
new_f.append(f)
new_f.sort(compare_by('birthday_dt'))
On Tue, Apr 15, 2008 at 8:25 PM, rkmr.em at gmail.com <rkmr.em at gmail.com> wrote:
> the memory usage of a python app keeps growing in a x86 64 linux
> continuously, whereas in 32 bit linux this is not the case. Python
> version in both 32 bit and 64 bit linux - 2.6.24.4-64.fc8
> Python 2.5.1 (r251:54863, Oct 30 2007, 13:45:26)
>
> i isolated the memory leak problem to a function that uses datetime
> module extensively. i use datetime.datetime.strptime,
> datetime.timedelta, datetime.datetime.now methods...
>
> i tried to get some info with guppy and the code goes like this
>
> while True:
> print heapy.heap().get_rp()
> print heapy.setref()
> users = globalstuff.q.get()
> for u in users:
> doalert(u)
>
>
More information about the Python-list
mailing list