wikipedia.py generator that extracts XML doesn't release memory
{'login': 'miyamonz', 'id': 6331508, 'node_id': 'MDQ6VXNlcjYzMzE1MDg=', 'avatar_url': 'https://avatars.githubusercontent.com/u/6331508?v=4', 'gravatar_id': '', 'url': 'https://api.github.com/users/miyamonz', 'html_url': 'https://github.com/miyamonz', 'followers_url': 'https://api.github.com/users/miyamonz/followers', 'following_url': 'https://api.github.com/users/miyamonz/following{/other_user}', 'gists_url': 'https://api.github.com/users/miyamonz/gists{/gist_id}', 'starred_url': 'https://api.github.com/users/miyamonz/starred{/owner}{/repo}', 'subscriptions_url': 'https://api.github.com/users/miyamonz/subscriptions', 'organizations_url': 'https://api.github.com/users/miyamonz/orgs', 'repos_url': 'https://api.github.com/users/miyamonz/repos', 'events_url': 'https://api.github.com/users/miyamonz/events{/privacy}', 'received_events_url': 'https://api.github.com/users/miyamonz/received_events', 'type': 'User', 'site_admin': False}
[]
[]
Hi @miyamonz 
Thanks for investigating this issue, good job !
It would be awesome to integrate your fix in the library, could you open a pull request ? OK! I'll send it later.
I tried downloading Japanese wikipedia, but it always failed because of out of memory maybe.

I found that the generator function that extracts XML data in wikipedia.py doesn't release memory in the loop.

https://github.com/huggingface/datasets/blob/13a5b7db992ad5cf77895e4c0f76595314390418/datasets/wikipedia/wikipedia.py#L464-L502

`root.clear()` intend to clear memory, but it doesn't.
https://github.com/huggingface/datasets/blob/13a5b7db992ad5cf77895e4c0f76595314390418/datasets/wikipedia/wikipedia.py#L490
https://github.com/huggingface/datasets/blob/13a5b7db992ad5cf77895e4c0f76595314390418/datasets/wikipedia/wikipedia.py#L494
I replaced them with `elem.clear()`, then it seems to work correctly.

here is the notebook to reproduce it.
https://gist.github.com/miyamonz/dc06117302b6e85fa51cbf46dde6bb51#file-xtract_content-ipynb
{'url': 'https://api.github.com/repos/huggingface/datasets/issues/2031/reactions', 'total_count': 0, '+1': 0, '-1': 0, 'laugh': 0, 'hooray': 0, 'confused': 0, 'heart': 0, 'rocket': 0, 'eyes': 0}