Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 674425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:42:19+00:00 2026-05-14T00:42:19+00:00

I have the following script 186.py: S=[] study=set([524287]) tmax=10**7 D={} DF={} dudcount=0 callcount=0 def

  • 0

I have the following script 186.py:

S=[]
study=set([524287])

tmax=10**7
D={}
DF={}
dudcount=0
callcount=0

def matchval(t1,t2):
    if t1==t2:
        global dudcount
        dudcount+=1
    else:
        global callcount
        callcount+=1
        D.setdefault(t1,set([]))
        D.setdefault(t2,set([]))
        D[t1].add(t2)
        if t1 in D[t2]:
            DF.setdefault(t1,set([]))
            DF[t1].add(t2)
            DF.setdefault(t2,set([]))
            DF[t2].add(t1)

for k in xrange(27):
    t1=(100003 - 200003*(2*k+1) + 300007*(2*k+1)**3)%(1000000)
    S.append(t1)
    t2=(100003 - 200003*(2*k+2) + 300007*(2*k+2)**3)%(1000000)
    S.append(t2)
    matchval(t1,t2)

t1=(100003 - 200003*(55) + 300007*(55)**3)%(1000000)
S.append(t1)
t2=(S[31]+S.pop(0))%(1000000)
S.append(t2)
matchval(t1,t2)

for k in xrange(29,tmax+1):
    t1=(S[31]+S.pop(0))%(1000000)
    S.append(t1)

    t2=(S[31]+S.pop(0))%(1000000)
    S.append(t2)
    matchval(t1,t2)

D.setdefault(524287,set([]))
DF.setdefault(524287,set([]))
print D[524287]
print DF[524287]
print dudcount,callcount
print "Done"

The last line prints “Done” but python doesn’t exit when this happens. I type the following command:

$ time python 186.py

And get the results:

set([810528L, 582178L, 49419L, 214483L, 974071L, 651738L, 199163L, 193791L])
set([])
11 9999989
Done

But I have to ctrl+C to get the time:

real    34m18.642s
user    2m26.465s
sys     0m11.645s

After the program outputs “Done” python CPU usage is very little… but the memory usage continues to grow… I used ctrl+C once it got to 80% of my system memory (its an old system).

What is going on here? What is the program doing after Done is printed? Shouldn’t it be done?

Thanks,
Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:42:20+00:00Added an answer on May 14, 2026 at 12:42 am

    I ran the same code on my 2 GHz dual-core laptop with 2GB RAM and it took about 1 1/2 minutes in Cygwin. The memory usage got up over 600 MB before the program quit and it took about 2-4 seconds after Done appeared for the prompt to come up and the memory to be released. However, I didn’t see any memory increase after the Done appeared.

    My guess is it has to do with memory management. After the Done appears, Python is working on freeing all of the memory which might take quite a while on an older machine with less RAM. I’m not sure why the memory actually increases unless there is just a delay in whatever is telling you how much memory is being used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following script: if (window.location.href.indexOf('env=P')) { env = 'P'; console.log(P); } else
I have following script which is aim to make a war file. def ant
I have the following script set as my VS2010 pre-build script: cd $(ProjectDir) C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe
I have following script and it works fine with FF and Safari. function swapimage(cid)
I have following small script to preview some text before submitting it to store
I have the following script that is working great, but I want to wrap
I have the following script. It replaces all instances of @lookFor with @replaceWith in
I have the following script, where the first and third document.writeline are static and
i have the following script import getopt, sys opts, args = getopt.getopt(sys.argv[1:], h:s) for
I have the following script which first shows only the first para of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.