Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm using mmap and re to search for words (1000+) in a file (9gig) without loading it into memory. I do this lots of times. In about 10 seconds I have 2.07 gigs of inactive memory (and 8.8mb free). Because the inactive memory goes up so fast I can't use purge. How can I prevent the inactive memory to get so high? Or is there a way to disable inactive memory while I'm running the program?

I use the following code:

def proteinID_to_uniprotID(protein):
    conversion_file = open('idmapping.dat')
    file_map = mmap.mmap(conversion_file.fileno(), 0, access=mmap.ACCESS_READ)
    file_map.seek(0)
    refseq_id_location = re.search(protein, file_map)
    if refseq_id_location != None:
        file_map.seek(refseq_id_location.start()-40)
        uniprotID = re.findall('\\n.*'+protein+'.*\\b', file_map.read(55))[0].split('\t')[0].strip()
        conversion_file.close()
        file_map.close()
        return uniprotID
    else:
        conversion_file.close()
        file_map.close()
        return 'not found'
share|improve this question
1  
Programming questions are off-topic, you might get better results at StackOverflow. – patrix Nov 4 '12 at 9:54
well I'm looking for a way to disable inactive memory in OSX so I thought maybe someone here knows – Niek de Klein Nov 4 '12 at 21:52
When used from C, mmap must be paired with munmap to free memory. Don't know whether this is required in Python as well. – patrix Nov 5 '12 at 5:28

closed as off topic by patrix, Stu Wilson, Michiel, Gerry, gentmatt Nov 5 '12 at 12:54

Questions on Ask Different are expected to relate to Apple hardware or software within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

Browse other questions tagged or ask your own question.