Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #630
| From | Bob Tennent <BobT@cs.queensu.ca> |
|---|---|
| Newsgroups | comp.os.linux.development.apps |
| Subject | Re: memory use |
| Date | 2011-02-02 21:16 +0000 |
| Organization | albasani.net |
| Message-ID | <slrnikjie3.bk0.BobT@linus.cs.queensu.ca> (permalink) |
| References | <slrnikj71n.9i7.BobT@linus.cs.queensu.ca> <iicg34$lr8$1@news.eternal-september.org> |
On Wed, 2 Feb 2011 20:50:45 +0000 (UTC), James Waldby wrote: > On Wed, 02 Feb 2011 18:02:31 +0000, Bob Tennent wrote: > >> A C program called musixflx is used as the second pass of a three-pass >> TeX-based system called musixtex. The program was the first C program >> written by a Fortran programmer. It has definitions as follows: >> >> # define MAX_BARS 2048 /* max number of bars */ >> >> int zbar[MAX_BARS], lr_repeat[MAX_BARS], raggedline[MAX_BARS], >> l_repeat[MAX_BARS], barno[MAX_BARS], ... >> >> double hardbarlength[MAX_BARS], softbarlength[MAX_BARS], >> width_leftrightrepeat[MAX_BARS], width_leftrepeat[MAX_BARS], >> ... >> Typically the number of bars in a piece is much smaller than MAX_BARS. >> >> Would it be best to >> >> + leave the code alone and let the virtual-memory functions of the >> operating system manage the memory > > Trying to reduce the 26KB used by those arrays probably is not > worthwhile. > >> + use "extensible" arrays (i.e., use realloc to copy small arrays to >> larger ones when necessary) > > If scores are running up against the 2048-bar limit, just double or > quadruple MAX_BARS.[1] The simplicity of fixed-size allocation is a > positive feature. However, if these arrays were fixed at megabyte > sizes and performance problems were occurring, allocating and > reallocating might be worth considering, to reduce cache line refilling. > >> And would there be any benefit to using a single array of structures >> instead of many parallel arrays? > > It looks like the code should have used structs when > it was written, but unless for some reason you want to rewrite the whole > program it probably would not make sense to change from using parallel > arrays to using structs. Thanks. Bob T.
Back to comp.os.linux.development.apps | Previous | Next — Previous in thread | Find similar
Re: memory use James Waldby <not@valid.invalid> - 2011-02-02 20:50 +0000 Re: memory use Bob Tennent <BobT@cs.queensu.ca> - 2011-02-02 21:16 +0000
csiph-web