Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Welcome to the Rockbox Technical Forums!

+  Rockbox Technical Forums
|-+  Rockbox General
| |-+  Rockbox General Discussion
| | |-+  Reducing RAM usage; why not buffer_alloc?
« previous next »
  • Print
Pages: [1]

Author Topic: Reducing RAM usage; why not buffer_alloc?  (Read 2533 times)

Offline dreamlayers

  • Developer
  • Member
  • *
  • Posts: 425
  • Boris Gjenero
    • My Blog
Reducing RAM usage; why not buffer_alloc?
« on: August 20, 2007, 02:28:28 PM »
I was wondering why recent versions of Rockbox use so much RAM even when running in ROM and so I examined the code.  I saw that firmware/common/unicode.c uses 64k for loading codepage files and I added ifdefs to disable loadable code pages.  I'm attaching a patch in case anyone is interested.  (I don't think it's worthy of being put in Flyspray.) I also disabled loadable languages and saved some RAM that way.  I'm not attaching a patch because what I did there is messy and not only about 20K is saved.

Then I thought of a better idea: instead of having  a preallocated array, allocate the memory with buffer_alloc the first time it is needed.  This way those who don't use a feature wouldn't have memory wasted by the feature.  This could be done for code pages, languages, fonts and perhaps more things.  (A loadable code page isn't used for ISO_8859_1 and UTF_8, english is built in and a font is built in.)  This technique is already used for buffers for the last.fm scrobbler and cue sheet functionality.  Is there any reason not to do this?

PS. .patch files are not accepted to I renamed it to .txt.  Then when I tried to post I was told I had posted already.  The error message due to the .patch attachment seemed to imply it wasn't posted and I can't find the post, so I'm posting again.  I hope this isn't a duplicate.
« Last Edit: August 20, 2007, 02:32:15 PM by Llorean »
Logged

Offline Llorean

  • Member
  • *
  • Posts: 12931
Re: Reducing RAM usage; why not buffer_alloc?
« Reply #1 on: August 20, 2007, 02:33:04 PM »
Instead of simply attempting to bypass the restrictions set on the forums, in the future please ask rather than simply intentionally ignoring rules and limits.
Logged

Offline dreamlayers

  • Developer
  • Member
  • *
  • Posts: 425
  • Boris Gjenero
    • My Blog
Re: Reducing RAM usage; why not buffer_alloc?
« Reply #2 on: August 20, 2007, 03:27:30 PM »
I see that .c and .h are permitted.  I could attach the whole .c file which I altered.  So, what is wrong with posting a patch file as an attachment?  

Is there any formal "forum rules" document which explains this?
Logged

Offline GodEater

  • Member
  • *
  • Posts: 2829
Re: Reducing RAM usage; why not buffer_alloc?
« Reply #3 on: August 20, 2007, 03:30:10 PM »
Patches go in FlySpray. Full stop. The End.

The Forum Guidelines, which you were supposed to have read, and agreed to when you signed up :

http://forums.rockbox.org/index.php?topic=5738.msg44378#msg44378
« Last Edit: August 20, 2007, 03:35:26 PM by GodEater »
Logged

Read The Manual Please

Offline dreamlayers

  • Developer
  • Member
  • *
  • Posts: 425
  • Boris Gjenero
    • My Blog
Re: Reducing RAM usage; why not buffer_alloc?
« Reply #4 on: August 20, 2007, 03:35:17 PM »
Quote from: GodEater on August 20, 2007, 03:30:10 PM
Patches go in FlySpray. Full stop. The End.
Even if it's something I was experimenting with and not something I'd like eventually merged into the code?
Logged

Offline GodEater

  • Member
  • *
  • Posts: 2829
Re: Reducing RAM usage; why not buffer_alloc?
« Reply #5 on: August 20, 2007, 03:35:58 PM »
See the forum guidelines in my post above (just edited with link - sorry if you missed it.)
Logged

Read The Manual Please

Offline linuxstb

  • Developer
  • Member
  • *
  • Posts: 1163
Re: Reducing RAM usage; why not buffer_alloc?
« Reply #6 on: August 20, 2007, 04:59:22 PM »
Quote from: dreamlayers on August 20, 2007, 02:28:28 PM
Is there any reason not to do this?

Yes - buffer_alloc can only be used at boot-time, so changing any of the settings you mentioned (font, language, code-page) would require a reboot in order for the setting to take effect.

There has been talk of removing that restriction - basically re-initialising Rockbox without a reboot, but afaik no-one has expressed an intention to do it.
Logged

Offline Lear

  • Developer
  • Member
  • *
  • Posts: 533
Re: Reducing RAM usage; why not buffer_alloc?
« Reply #7 on: August 21, 2007, 04:16:43 AM »
There's a limited form of re-initialization, but only for the swcodec playback system (e.g., to allow changes to the crossfade settings).

To allow a full re-initialization would probably require a fairly big restructuring of how Rockbox is initialized and how the buffer allocations are made. But getting the buffer allocations done in the right order isn't trivial, and has been the source of more than one hard to find bug, so a cleanup in this area could be nice.

Note that any change to a buffer-related setting would then cause playback to stop, at least temporarily, and any music would need to be re-buffered. So there are drawbacks too.
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox General
| |-+  Rockbox General Discussion
| | |-+  Reducing RAM usage; why not buffer_alloc?
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.091 seconds with 14 queries.