# Memory problems, system slow

## kirikou

Hello,

I have a big problem with my gentoo installation. I can almost not run more than one applications at the same time, because my system becomes so slow that it is impossible to use it.

I did a free -m with no applications launched and I got the following result. Surprinsigly, my memory was almost fully used...

```
free -m

             total       used       free     shared    buffers     cached

Mem:          1010        841        168          0        110        460

-/+ buffers/cache:        271        739

Swap:          980          0        980
```

Moreover, I can't compile azureus, because I get the following error:

```
[javac] The system is out of resources.

[javac] Consult the following stack trace for details.

[javac] java.lang.OutOfMemoryError: Java heap space
```

I tried the trick suggested in another thread (ANT_OPTS="-Xmx512M") but it doesn't work.

I don't know which files are relevant, so please ask me and I will post them.

Here is the output of emerge --info

```
Portage 2.1.5_rc5 (default-linux/x86/2007.0, gcc-4.1.1, glibc-2.7-r2, 2.6.24-gentoo-r3 i686)

=================================================================

System uname: 2.6.24-gentoo-r3 i686 Intel(R) Pentium(R) M processor 1.70GHz

Timestamp of tree: Mon, 21 Apr 2008 07:15:01 +0000

ccache version 2.4 [enabled]

app-shells/bash:     3.2_p33

dev-java/java-config: 1.3.7, 2.1.5

dev-lang/python:     2.4.4-r11, 2.5.2-r2

dev-python/pycrypto: 2.0.1-r6

dev-util/ccache:     2.4-r7

sys-apps/baselayout: 2.0.0

sys-apps/openrc:     0.2.2

sys-apps/sandbox:    1.2.18.1-r2

sys-devel/autoconf:  2.13, 2.62

sys-devel/automake:  1.5, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.1

sys-devel/binutils:  2.18-r1

sys-devel/gcc-config: 1.4.0-r4

sys-devel/libtool:   1.5.26

virtual/os-headers:  2.6.25-r1

ACCEPT_KEYWORDS="x86 ~x86"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-O2 -march=pentium-m -pipe"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"

CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c /etc/udev/rules.d"

CXXFLAGS="-O2 -march=pentium-m -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="ccache collision-protect distlocks metadata-transfer parallel-fetch sandbox sfperms strict unmerge-orphans userfetch"

GENTOO_MIRRORS="ftp://mirror.switch.ch/mirror/gentoo ftp://ftp.solnet.ch/mirror/Gentoo http://gentoo.mirror.solnet.ch"

LANG="en_US.utf8"

LC_ALL="en_US.utf8"

LDFLAGS=""

LINGUAS="en fr"

MAKEOPTS="-j2"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/portage/local/layman/java-overlay /usr/local/portage"

SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"

USE="X a52 aac acl acpi alsa apache2 bash-completion berkdb bonobo bzip2 cddb cdparanoia cdr cli cracklib crypt cscope cups dbus dri dv dvd dvdr dvdread encode exif fam fbcon ffmpeg firefox flac fortran ftp gcj gdbm gif gnome gphoto2 gpm gstreamer gtk hal hardened iconv imagemagick imap imlib ipod isdnlog java javascript jpeg jpeg2k junit lm_sensors mad matroska midi mime mmx mng mp3 mpeg mplayer mudflap musepack ncurses nls nptl nptlonly nsplugin nvidia ogg opengl openmp pam pcre pdf perl pmu png pppd python quicktime readline reflection ruby sdl session speex spell spl sse sse2 ssl svg svga tcpd tetex theora threads tiff truetype unicode usb vcd vim-syntax vorbis wifi win32codecs wxwindows x264 x86 xinerama xml xorg xv xvid xvmc zlib" ALSA_CARDS="intel8x0" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en fr" USERLAND="GNU" VIDEO_CARDS="nvidia vesa fbdev"

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
```

I can post my kernel's config file if needed (it didn't do it because it's quite a big file)

Any help would be very apreciated, because I have absolutely no idea about the reason of this slowliness.

Thank you very much.

----------

## BradN

Actually, your memory's not almost full - you need to go by the "-/+ buffers/cache:" line, which says that about 3/4 of your memory is available (linux uses it for disk cache when programs don't need it).  Additionally, none of your swap memory is used.

As far as the slowness goes, that I'm not sure what would be causing it.  If you've got a P4 system or a laptop with a clogged fan, it may be thermally throttling the speed down to avoid overheating, but that's all I can think of off the top of my head.

I would try watching the memory usage of javac while you compile azureus - it could be that it's requesting a huge chunk of memory (I see this often with compiling certain C++ apps) and is a bit unreasonable with its requirements.  A workaround may be switching to a newer/older java version to compile azureus, then switching it back.

----------

## kirikou

I've got a Pentium-M system. 

I thought that this slowness might be due to a kernel misconfiguration, and therefore I tried compiling a kernel with genkernel, but it remains slow.

I can see no other reasons for my system being so slow...

 *Quote:*   

> I would try watching the memory usage of javac while you compile azureus

 

How do I do that?

Thank you very much!

----------

## BradN

I'd recommend using a utility like "top" in another shell - if you run that and then type the letters O q (that's the capital o, not the number), it will sort by resident memory usage, which is what you'd be interested in here.

----------

## kirikou

I did what you suggested.

java uses only about 8.7% of the memory, but between 50 and 60% of the CPU.

I forgot to say that I set PORTAGE_NICENESS to 15.

During the compilation (before it fails), my system become almost unresponsive, despite the high niceness of portage...

----------

## coolsnowmen

are you out of hard drive space?

```
df -h
```

----------

## mantoo

 *kirikou wrote:*   

> 
> 
> I tried the trick suggested in another thread (ANT_OPTS="-Xmx512M") but it doesn't work.
> 
> 

 

this is a prob which i found first time on my machine, while trying to update from azureus 3.0.5.0 to 3.0.5.2

i also tried that option, further i also tried that:

```
export ANT_OPTS="-Xms512m -Xmx512m"
```

and even tried to raise to 1024 mb... (ive got 2 gigs of ram, dualcore 2x2 ghz....)

didnt find any soultion yet.... ??

oh, my output:

```
free -m

             total       used       free     shared    buffers     cached

Mem:          2026       1727        299          0         93       1170

-/+ buffers/cache:        463       1563

Swap:          980          3        976

```

----------

## kirikou

My root partition is full at 89%, there is 1.6 Go space left...

----------

## peakeyed

I have all the same symptoms that you have described on my newly built box. I don't have the time to investigate yet. I hope you find a fix. Good luck.

----------

## energyman76b

 *kirikou wrote:*   

> I did what you suggested.
> 
> java uses only about 8.7% of the memory, but between 50 and 60% of the CPU.
> 
> I forgot to say that I set PORTAGE_NICENESS to 15.
> ...

 

set portage niceness to 19. Its better in every aspect (have a look into /usr/src/linux/Documentation why it is a good choice for compiling). 

check that your are not using some energy saving stuff that pins your mhz at the lowest number.

check your bios.

----------

## kirikou

I set my portage niceness to 19 as recommended.

My CPU runs at full power 1.7 Ghz (pentium-m).

 *Quote:*   

> check your bios.

 

What do you mean ?

----------

## energyman76b

well, make sure that your memory runs at the correct speed and that 'Spread Spectrum' stuff is disabled (won't help with speed, but does help with stability).

----------

## BradN

Actually spread spectrum makes the clock signal slightly irregular on purpose, to reduce EMI interference on that specific frequency.  By altering the signal, it spreads out the frequencies that end up emitted a bit, and depending how tight the timings already are for devices on the bus in question, this could actually hurt reliability slightly.

----------

## Carsomyr

I've seen at east one install running very slowly due to frequency scaling keeping the CPU at minimum because no module was loaded.

Try

```
cat /proc/cpuinfo
```

 and check that the CPU really is running at the correct speed.

Also try

```
modprobe acpi_cpufreq
```

 and then check the speed again

----------

## kirikou

I did a cat /proc/cpuinfo, all seems normal (my processor frequency varies between 600Mhz and 1.7Ghz.

I have no module acpi_cpufreq. However if I do a grep -i acpi_cpufreq /usr/src/linx/.config I got the following entries

```
CONFIG_X86_ACPI_CPUFREQ=m

# CONFIG_X86_ACPI_CPUFREQ_PROC_INTF is not set
```

----------

