memory counsumption

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

memory counsumption

imgrey
Good Day

I tried to feed 1.5Mb email message to Header(), it consumed about !Gb
of memory and them was killed:

string = read('email_message').decode('utf-8')
decode_header(Header(string))

strace -f -c -p showed:
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 97.98    0.001504           9       173           munmap
  1.04    0.000016           0       124           mremap
  0.98    0.000015           0       248           mmap2
  0.00    0.000000           0        75           brk
------ ----------- ----------- --------- --------- ----------------
100.00    0.001535                   620           total


Could you please tell where to look to find a solution for this issue ?
_______________________________________________
Email-SIG mailing list
[hidden email]
Your options: http://mail.python.org/mailman/options/email-sig/lists%40nabble.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: memory counsumption

Mark Sapiro-3
Vitaliyi wrote:
>
>I tried to feed 1.5Mb email message to Header(), it consumed about !Gb
>of memory and them was killed:
>
>string = read('email_message').decode('utf-8')
>decode_header(Header(string))
>
[...]
>
>Could you please tell where to look to find a solution for this issue ?


Start with the documentation. The Header() constructor accepts a single
header value, not an entire email message. the decode_header function
also accepts a single header value, not a Header instance.

You maybe want something like

msg = email.message_from_file(open('email_message'))
subj = msg['subject']

Then you could do things like email.header.Header(subj) to create a
Header instance or decode_header(subj) to decode an RFC 2447 encoded
subject.

--
Mark Sapiro <[hidden email]>        The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

_______________________________________________
Email-SIG mailing list
[hidden email]
Your options: http://mail.python.org/mailman/options/email-sig/lists%40nabble.com
Loading...