Manual iteration over dataloader memory leak, how to store the iterator correctly?

Hi everyone,

I’ve been experiencing this issue:

From what I understood I should do is store the iterator which I do.
I.e. iterds = iter(dataloader)

then I get the item with next(iterds)

Is this also using the cycle() method that is described by the OP of the old issue?

How would I do it correctly then?

Many thanks in advance!

Did anyone have an answer to this?

It’s unclear what your exact use case is, so could you post a minimal and executable code snippet reproducing the issue?