Giter VIP home page Giter VIP logo

Comments (5)

ecederstrand avatar ecederstrand commented on May 26, 2024 2

.all() is greedy and fetches all items in one go. Attachments load their content when accessing attachment.content or attachment.item, which will increase your memory usage while iterating.

If you have attributes that you don't care about, you can optimize your memory usage by fetching only the attributes you need:

for m in account.inbox.all().only('item_id', 'changekey', 'attachments'):
    ...

Finally, res = account.inbox.all() creates an internal cache of the search results so a second iteration over res does not hit the server. If you will never need this cache, you can add .iterator() at the end of your filter, i.e:

for m in account.inbox.all().iterator():
    ...

from exchangelib.

ecederstrand avatar ecederstrand commented on May 26, 2024 1

Closed this with a recommendation to use this optimisation and the latest 1.7.5 release:

for m in account.inbox.all().only('item_id', 'changekey', 'attachments').iterator():
    ...
    for attachment in item.attachments:
        ...

If this doesn't help, please provide measurements or other insight into the problem.

from exchangelib.

ecederstrand avatar ecederstrand commented on May 26, 2024

Does Python crash at 600MB usage? How much raw data is the 5000 messages in total? If your inbox contains large attachments, 600MB may not be unreasonable.

from exchangelib.

ecederstrand avatar ecederstrand commented on May 26, 2024

638995b clears some elements after XML parsing, which should ease the memory pressure a bit. Can you try if that helps?

A more optimal solution would be to change from a greedy XML parser to an iterating parser, but that would be quite painful.

from exchangelib.

ecederstrand avatar ecederstrand commented on May 26, 2024

Hi @KarelCoudijzer Did you get to the bottom of this? If you are still having problems, I think #52 would make it possible to create a generator that makes .all() non-greedy.

from exchangelib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.