WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Tips for lowering memory usage to a minimum?  (Read 5423 times)

Offline theYinYeti

  • Full Member
  • ***
  • Posts: 177
    • YetI web site
Tips for lowering memory usage to a minimum?
« on: March 04, 2012, 01:46:04 PM »
Hi! I use an old laptop with 32MB RAM; I thought it was 48 but no, it is 32… I wish to use TinyCore instead of the current DSL.

I am aware that I’ll need to do things that are not standard. But I’m willing to do this as long as the method is reproducible and still based on upstream releases.

I’m thinking of two things:
1º— For a start, I’d like to remove as much in-RAM loading as possible. So what are the things that are loaded? vmlinuz then core.gz, I suppose, and then what?
2º— Is there any existing module, so that RAM is compressed with a fast and light-on-CPU algorithm? That way, I’d have a bit more than 32MB…

Thanks for any pointers. Yves.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11050
Re: Tips for lowering memory usage to a minimum?
« Reply #1 on: March 04, 2012, 02:06:07 PM »
2) Yes, zram, and we already enable it by default ;)
The only barriers that can stop you are the ones you create yourself.

Offline theYinYeti

  • Full Member
  • ***
  • Posts: 177
    • YetI web site
Re: Tips for lowering memory usage to a minimum?
« Reply #2 on: March 04, 2012, 02:17:50 PM »
Good! So 2º is done with :)

With a closer look, I already have a couple of more specific questions:
3º— I see that / is rootfs. I assume this “partition” is loaded in memory from core.gz. And I see that df reports this “partition” as being 24MB and only 44% full. Shouldn’t it be close to 100% full instead, as all software is loop-mounted? Could I reclaim some RAM on those 24MB?
4º— I also see that /tmp is tmpfs. As I have my own /tmp on disk, is there a method, as for home and opt, to tell TC to use a given partition for /tmp storage?

Well… now that I think about it, I have one more question:
5º— Late boot is just a series of “No space left on device”. Yet, as noted above, rootfs is only 44% full. The only “partitions” that are 100% full are the /dev/loop*, as should be I guess. So what is considered full on boot, to give me the messages I get?

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: Tips for lowering memory usage to a minimum?
« Reply #3 on: March 04, 2012, 02:28:39 PM »
Quoted from  http://forum.tinycorelinux.net/index.php/topic,12714.0/topicseen.html#lastPost
Quote
4. Use the  nozswap  boot code

This may be counterproductive, especially on a low-ram system as this.
I'll continue this here since a new thread was created. I meant for the  nozswap  boot code to be used together
with a swap file. While not as fast, he won't be consuming RAM for swap storage, of which he does not have
much to begin with.

@theYinYeti: Using a persistent  /home  and  /opt  will keep them from using up RAM.

Offline theYinYeti

  • Full Member
  • ***
  • Posts: 177
    • YetI web site
Re: Tips for lowering memory usage to a minimum?
« Reply #4 on: March 04, 2012, 02:42:30 PM »
I meant for the  nozswap  boot code to be used together
with a swap file. While not as fast, he won't be consuming RAM for swap storage, of which he does not have
much to begin with.
Do I have to use a swap file, even when I already have a /dev/sda1 swap partition?

When I run with persistent opt and home, but without any swap-related option, I still have memory-related errors, for /var/run/… and /tmp/…

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: Tips for lowering memory usage to a minimum?
« Reply #5 on: March 04, 2012, 02:47:53 PM »
Hi theYinYeti
If you have a swap partition you don't need a swap file. You can use the boot code   swap=sda1

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11050
Re: Tips for lowering memory usage to a minimum?
« Reply #6 on: March 04, 2012, 03:06:04 PM »
You can use the boot code   swap=sda1

There's no such bootcode, as far as I know?
The only barriers that can stop you are the ones you create yourself.

Offline theYinYeti

  • Full Member
  • ***
  • Posts: 177
    • YetI web site
Re: Tips for lowering memory usage to a minimum?
« Reply #7 on: March 04, 2012, 03:18:13 PM »
Actually, the swap partition is seen: at some point of the boot process, there is a message telling that available swap partition(s) are enabled, and free shows it. I just hope this swap is seen soon enough so that no RAM is lost because of a temporary lack of swap. If I understand correctly, I might gain a bit of RAM by using nozswap along with my swap partition. Thank you curaga and Rich :)

I’m still interested in answers to my questions 1, 3, 4 and 5  ;)

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11705
Re: Tips for lowering memory usage to a minimum?
« Reply #8 on: March 04, 2012, 03:40:16 PM »
Hi curaga
Your right, guess I'll remove that boot code from my systems. I must have copied that from somewhere without
checking the facts.

3. If the rootfs is full, there won't be any space to write to, so no, it should not be 100% full.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11050
Re: Tips for lowering memory usage to a minimum?
« Reply #9 on: March 05, 2012, 10:18:07 AM »
4) no.

3, 5) You're likely out of inodes even if there is space left. But still it is very low on ram, close to the limits.
The only barriers that can stop you are the ones you create yourself.

Offline theYinYeti

  • Full Member
  • ***
  • Posts: 177
    • YetI web site
Re: Tips for lowering memory usage to a minimum?
« Reply #10 on: March 11, 2012, 11:06:17 AM »
I did my home-work, and I found some answers  :)
1º: All I need is there:
http://wiki.tinycorelinux.net/wiki:the_boot_process
http://wiki.tinycorelinux.net/wiki:custom_kernel
http://wiki.tinycorelinux.net/wiki:remastering
3º: I see that core.gz:/init remounts / with size 90% (maximum), without setting the default value. I may try and set instead an absolute value based on the result of the “du” command…

For 4º and 5º, I’m still in the dark  :(
I don’t see anywhere in the core.gz file, where /tmp is mounted, much less where it is set to tmpfs. And while curaga may be right about the cause for the seemingly cause-less “no space left”, I don’t know how to enable more inodes.

Oh, and while I’m at it, let me add a sixth question:
6º— What is the purpose of the “noembed” boot option? I see in core.gz:/init, that when set, it duplicates / inside /mnt, and then switch_root to it; what is the point? / is in memory, and /mnt is also in memory… so, what is gained by this noembed option?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11050
Re: Tips for lowering memory usage to a minimum?
« Reply #11 on: March 11, 2012, 01:03:05 PM »
While you can set the number of tmpfs inodes with the nr_inodes mount option, it's too late to do that in /init; the limit has already been met at that point and some files are missing.

noembed is useful for proprietary installers etc that need to see the free space on /.
The only barriers that can stop you are the ones you create yourself.