Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 228075 - sys-apps/portage - emerge runs out of memory
Summary: sys-apps/portage - emerge runs out of memory
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: AMD64 Linux
: High major (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 210077
  Show dependency tree
 
Reported: 2008-06-18 12:22 UTC by Jeremy Stent
Modified: 2008-06-20 13:43 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Output of emerge --info (emerge_info.txt,15.42 KB, text/plain)
2008-06-18 12:23 UTC, Jeremy Stent
Details
explicitly call gc.collect() to try and free memory (garbage_collect.patch,661 bytes, patch)
2008-06-18 18:49 UTC, Zac Medico
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Stent 2008-06-18 12:22:14 UTC
Emerging any package runs out of memory.  Probably in the checking for file collisions.

Reproducible: Always

Steps to Reproduce:
1.  Run emerge AnyPackage
2.  Will not complete - runs out of memory
Actual Results:  
>>> Done.
* checking 35 files for package collisions
>>> Merging dev-libs/lzo-2.03 to /
Traceback (most recent call last):
  File "/usr/bin/emerge", line 9277, in <module>
    retval = emerge_main()
  File "/usr/bin/emerge", line 9271, in emerge_main
    myopts, myaction, myfiles, spinner)
  File "/usr/bin/emerge", line 8687, in action_build
    retval = mergetask.merge(pkglist, favorites, mtimedb)
  File "/usr/bin/emerge", line 5937, in merge
    return self._merge(mylist, favorites, mtimedb)
  File "/usr/bin/emerge", line 6218, in _merge
    blockers=self._find_blockers(pkg))
  File "/usr/lib64/portage/pym/portage.py", line 5597, in merge
    mydbapi=mydbapi, prev_mtimes=prev_mtimes)
  File "/usr/lib64/portage/pym/portage.py", line 10552, in merge
    mydbapi=mydbapi, prev_mtimes=prev_mtimes)
  File "/usr/lib64/portage/pym/portage.py", line 10560, in _merge
    cleanup=cleanup, mydbapi=mydbapi, prev_mtimes=prev_mtimes)
  File "/usr/lib64/portage/pym/portage.py", line 10045, in treewalk
    vartree=self.vartree)
  File "/usr/lib64/portage/pym/portage.py", line 5145, in doebuild
    mysettings, debug=debug, free=1, logfile=logfile)
  File "/usr/lib64/portage/pym/portage.py", line 3011, in spawn
    set_term_size(rows, columns, slave_fd)
  File "/usr/lib64/portage/pym/output.py", line 352, in set_term_size
    spawn(cmd, env=os.environ, fd_pipes={0:fd})
  File "/usr/lib64/portage/pym/portage_exec.py", line 215, in spawn
    pid = os.fork()
OSError: [Errno 12] Cannot allocate memory


Expected Results:  
Successful emerge

If I use ebuild package compile install qmerge, then it succeeds, it seems to be just emerge that is broken.
I have 6G of RAM and 4G of swap space.  I have a LARGE collection of installed programs.  (du -sh /var/db/pkg/ claims 1.5G or 1536100)  Possibly 100820 packages installed.

will attach output of emerge --info
Comment 1 Jeremy Stent 2008-06-18 12:23:13 UTC
Created attachment 157427 [details]
Output of emerge --info

This was too large to put in a comment, so attached it.
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-18 15:09:14 UTC
(In reply to comment #1)
> Created an attachment (id=157427) [edit]
> Output of emerge --info
> 
> This was too large to put in a comment, so attached it.

That's because you enabled every last USE flag in the book. Sorry, I can't see any scenario where that would be useful. My advice is for you to either prune the USE variable to the basics you need or to get more RAM. :)
Comment 3 Jeremy Stent 2008-06-18 15:13:02 UTC
I haven't edited the use flags in weeks.  Emerge only started running out of memory last week.  Has something changed in how emerge handles the USE flags?
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2008-06-18 15:41:18 UTC
(In reply to comment #3)
> I haven't edited the use flags in weeks.  Emerge only started running out of
> memory last week.  Has something changed in how emerge handles the USE flags?

There's a hint of a chance that this may be a valid question.
Comment 5 Zac Medico gentoo-dev 2008-06-18 18:23:42 UTC
Bug #218378 is seems similar, but that was with listdir() rather than fork().
Comment 6 Zac Medico gentoo-dev 2008-06-18 18:49:34 UTC
Created attachment 157483 [details, diff]
explicitly call gc.collect() to try and free memory

(In reply to comment #0)
> If I use ebuild package compile install qmerge, then it succeeds, it seems to
> be just emerge that is broken.
> I have 6G of RAM and 4G of swap space.  I have a LARGE collection of installed
> programs.  (du -sh /var/db/pkg/ claims 1.5G or 1536100)  Possibly 100820
> packages installed.

I hadn't realize how large your number of installed packages is. Do you really have 100,820 packages installed? That doesn't seem right because there fewer than 30,000 ebuilds in the portage tree. With portage-2.1.5.x you can use this command to get an exact count:

portageq match / "" | wc -l

Perhaps the 'Cannot allocate memory' error is legitimate. Considering that the initial dep calculation succeeded, it seems like should be enough memory though. Can you try this patch to see if it helps?
Comment 7 Jeremy Stent 2008-06-18 20:19:22 UTC
You are correct about my packages.  I had tried to count the number of subdirectories under /var/db/pkg, but messed up.  That command to count the packages returns 9821.
Have applied the patch and it seems to have corrected the issue.
Thank you for your quick and helpful response.
Will I have to keep applying this patch?
Comment 8 Zac Medico gentoo-dev 2008-06-18 21:35:27 UTC
I've committed the patch in svn r10717 and it will be in the next release.
Comment 9 Zac Medico gentoo-dev 2008-06-20 13:43:48 UTC
This is fixed in 2.2_rc1.