Optimizing structure memory allocation

How is the memory allocated for structures? I need to optimize the
memory usage and bit fields are not doing the trick.

Any details about the memory allocation for the structures would be a
great help.

PS - I already have asked this in gcc group. Please refrain from
directing me towards other groups.
0
rahulsinner (161)
5/27/2008 12:25:47 PM
comp.lang.c 29878 articles. 34 followers. spinoza1111 (3247) is leader. Post Follow

14 Replies
170 Views

Similar Articles

[PageSpeed] 15
rahul said:

> How is the memory allocated for structures?

"A structure type describes a sequentially allocated set of member 
objects", says the Standard.

Later, it adds: "If the objects pointed to are members of the same 
aggregate object, pointers to structure members declared later compare 
higher than pointers to members declared earlier in the structure".

Finally, "There may also be unnamed padding at the end of a structure or 
union, as necessary to achieve the appropriate alignment were the 
structure or union to be a member of an array."

<snip>

> PS - I already have asked this in gcc group. Please refrain from
> directing me towards other groups.

Gladly, if you are happy to accept that the answers you get here will be 
related to what the language guarantees, rather than which particular 
choice an implementation might make where the language offers such a 
choice.

-- 
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
0
rjh (10790)
5/27/2008 12:44:42 PM
In article <859569b1-e7e0-4711-969e-8960bc5df728@i36g2000prf.googlegroups.com>,
rahul  <rahulsinner@gmail.com> wrote:

>How is the memory allocated for structures? I need to optimize the
>memory usage and bit fields are not doing the trick.
>
>Any details about the memory allocation for the structures would be a
>great help.

You'll probably get better help if you ask a more specific question.
Show us what you want to put in the structure.

The members of a struct are stored in the order you specify.  Some
members may have types that require a particular alignment, typically
equal to their size.  For example, while chars can go anywhere you may
find that if ints are 4 bytes long then they are always placed on
4-byte boundaries.  This is common even if the processor allows
arbitrary alignment, because it's usually faster to access
suitably-aligned data.

Suppose shorts are 2 bytes and ints are 4, with corresponding
alignment requirements, and you want to store 2 chars, a short, and an
int in your struct.  These could fit in 8 bytes, and will if you order
them correctly, for example

  struct foo {
    int a;
    short b;
    char c, d;
  };

but if you do

  struct foo2 {
    char c;
    int a;
    char d;
    short b;
  };

it will take 12 bytes, because the 3 bytes after c and the byte after d
are wasted.

If you use bitfields, then you have to consider similar issues at the
bit level.  Adjacent bitfields that fit within a "unit" (probably an
int) will be packed together, so don't spread them out amongst other
members of the struct, and try to order them so that they don't go
over too many int boundaries.

-- Richard
-- 
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)
0
richard91 (3692)
5/27/2008 12:53:47 PM
rahul wrote:
> 
> How is the memory allocated for structures? I need to optimize
> the memory usage and bit fields are not doing the trick.
> 
> Any details about the memory allocation for the structures would
> be a great help.
> 
> PS - I already have asked this in gcc group. Please refrain from
> directing me towards other groups.

If you are using gcc, then a gcc group is appropriate.  This one is
not.  A compiler system can use any method of memory allocation it
pleases, so long as it works.

-- 
 [mail]: Chuck F (cbfalconer at maineline dot net) 
 [page]: <http://cbfalconer.home.att.net>
            Try the download section.

** Posted from http://www.teranews.com **
0
cbfalconer (19194)
5/27/2008 6:41:32 PM
On 27 May 2008 at 12:25, rahul wrote:
> How is the memory allocated for structures? I need to optimize the
> memory usage and bit fields are not doing the trick.
>
> PS - I already have asked this in gcc group. Please refrain from
> directing me towards other groups.

You might want to look at gcc's packed attribute, which "specifies that
a variable or structure field should have the smallest possible
alignment - one byte for a variable, and one bit for a field, unless you
specify a larger value with the aligned attribute."

You can either pack specific fields, e.g.

struct foo {
  char a;
  int b __attribute__((packed));
};

or whole structs at once, e.g.

struct bar {
  int a;
  char b;
  int c;
  char d;
  int e;
} __attribute__((packed));

0
nospam59 (11087)
5/27/2008 7:18:08 PM
Antoninus Twink <nospam@nospam.invalid> writes:
> On 27 May 2008 at 12:25, rahul wrote:
>> How is the memory allocated for structures? I need to optimize the
>> memory usage and bit fields are not doing the trick.
>>
>> PS - I already have asked this in gcc group. Please refrain from
>> directing me towards other groups.
>
> You might want to look at gcc's packed attribute,
[...]

which is, of course, off-topic in comp.lang.c.

rahul, you asked us not to direct you to other groups.  Why?
Questions about gcc-specific features are appropriate in gnu.gcc.help;
they are not appropriate in comp.lang.c.

Or you can consult the extensive documentation that comes with gcc.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
kst-u (21963)
5/27/2008 7:33:34 PM
In article <g1h08r$1c9f$1@pc-news.cogsci.ed.ac.uk>,
Richard Tobin <richard@cogsci.ed.ac.uk> wrote:
>In article <859569b1-e7e0-4711-969e-8960bc5df728@i36g2000prf.googlegroups.com>,
>rahul  <rahulsinner@gmail.com> wrote:

>>How is the memory allocated for structures? I need to optimize the
>>memory usage and bit fields are not doing the trick.

>The members of a struct are stored in the order you specify.

Expanding slightly on Richard's answer for emphasis:

C *requires* that structure members be placed in the order given,
and in increasing address order in memory. Storing the members in
the order coded is not just a matter of convention: it is part
of the language definition. As is the fact that alignment restrictions
exist and are adhered to by the compiler by adding unnamed padding
between structure members if needed (or advised) by the target machine.
-- 
  "All is vanity."                                   -- Ecclesiastes
0
roberson2 (8606)
5/27/2008 7:44:51 PM
roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
> In article <g1h08r$1c9f$1@pc-news.cogsci.ed.ac.uk>,
> Richard Tobin <richard@cogsci.ed.ac.uk> wrote:
>>In article <859569b1-e7e0-4711-969e-8960bc5df728@i36g2000prf.googlegroups.com>,
>>rahul  <rahulsinner@gmail.com> wrote:
>
>>>How is the memory allocated for structures? I need to optimize the
>>>memory usage and bit fields are not doing the trick.
>
>>The members of a struct are stored in the order you specify.
>
> Expanding slightly on Richard's answer for emphasis:
>
> C *requires* that structure members be placed in the order given,
> and in increasing address order in memory. Storing the members in
> the order coded is not just a matter of convention: it is part
> of the language definition. As is the fact that alignment restrictions
> exist and are adhered to by the compiler by adding unnamed padding
> between structure members if needed (or advised) by the target machine.

Right, but it's perfectly legal for the alignment restriction to be
"any alignment is ok".  It's also legal (but silly) for the compiler
to insert padding whether it's required for alignment or not.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
kst-u (21963)
5/27/2008 8:02:33 PM
On Tue, 27 May 2008 13:02:33 -0700, Keith Thompson wrote:
> Right, but it's perfectly legal for the alignment restriction to be "any
> alignment is ok".  It's also legal (but silly) for the compiler to
> insert padding whether it's required for alignment or not.

It's not silly if older systems required a particular alignment, newer 
systems don't, but the compiler still inserts padding to maintain binary 
compatibility with those older systems. It's good that implementors are 
given a lot of freedom in choosing what works best for their systems.
0
truedfx (1926)
5/27/2008 8:35:12 PM
Keith Thompson wrote:
> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
>> 
>> C *requires* that structure members be placed in the order given,
>> and in increasing address order in memory. Storing the members in
>> the order coded is not just a matter of convention: it is part
>> of the language definition. As is the fact that alignment restrictions
>> exist and are adhered to by the compiler by adding unnamed padding
>> between structure members if needed (or advised) by the target machine.
> 
> Right, but it's perfectly legal for the alignment restriction to be
> "any alignment is ok".  It's also legal (but silly) for the compiler
> to insert padding whether it's required for alignment or not.

     The ambiguity lies in "requirement."  On one popular
platform, for example, a `double' can be accessed at any
address divisible by four, but can be accessed more quickly
if the address is also divisible by eight.  Should the
alignment "requirement" be taken as four or as eight?

-- 
Eric.Sosman@sun.com
0
Eric.Sosman (4552)
5/27/2008 9:03:59 PM
Eric Sosman <Eric.Sosman@sun.com> writes:
> Keith Thompson wrote:
>> roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson) writes:
>>> C *requires* that structure members be placed in the order given,
>>> and in increasing address order in memory. Storing the members in
>>> the order coded is not just a matter of convention: it is part
>>> of the language definition. As is the fact that alignment restrictions
>>> exist and are adhered to by the compiler by adding unnamed padding
>>> between structure members if needed (or advised) by the target machine.
>> Right, but it's perfectly legal for the alignment restriction to be
>> "any alignment is ok".  It's also legal (but silly) for the compiler
>> to insert padding whether it's required for alignment or not.
>
>     The ambiguity lies in "requirement."  On one popular
> platform, for example, a `double' can be accessed at any
> address divisible by four, but can be accessed more quickly
> if the address is also divisible by eight.  Should the
> alignment "requirement" be taken as four or as eight?

Could be either.  My point is that the compiler is allowed to insert,
say, 16 bytes of padding, even if it doesn't help performance at all.

It's just an example of the kind of assumption that shouldn't be made
in portable code.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
kst-u (21963)
5/27/2008 9:14:36 PM
In article <ln8wxvqwjn.fsf@nuthaus.mib.org>,
Keith Thompson  <kst-u@mib.org> wrote:

>Could be either.  My point is that the compiler is allowed to insert,
>say, 16 bytes of padding, even if it doesn't help performance at all.
>
>It's just an example of the kind of assumption that shouldn't be made
>in portable code.

I disagree (though obviously only up to a point).  It's perfectly
legal for a compiler to insert pointless alignment, but it's also
reasonable to assume that it won't.  For example, given any sensible
alignment scheme you will get good packing by ordering members by
decreasing size (int then short then char for example).  A portable
program can quite reasonably order structure members on this
assumption, and if it turns out to be false then the blame should be
assigned to the implementation, not the programmer.

We aren't obliged to ignore common sense in our programs, even if
conforming compilers can defeat it.

-- Richard
-- 
In the selection of the two characters immediately succeeding the numeral 9,
consideration shall be given to their replacement by the graphics 10 and 11 to
facilitate the adoption of the code in the sterling monetary area. (X3.4-1963)
0
richard91 (3692)
5/27/2008 9:30:18 PM
Keith Thompson wrote:
> Eric Sosman <Eric.Sosman@sun.com> writes:
>> Keith Thompson wrote:
>>> [...] It's also legal (but silly) for the compiler
>>> to insert padding whether it's required for alignment or not.
>>     The ambiguity lies in "requirement."  On one popular
>> platform, for example, a `double' can be accessed at any
>> address divisible by four, but can be accessed more quickly
>> if the address is also divisible by eight.  Should the
>> alignment "requirement" be taken as four or as eight?
> 
> Could be either.  My point is that the compiler is allowed to insert,
> say, 16 bytes of padding, even if it doesn't help performance at all.

     ... and my point was about the word "silly:" Until you
can nail down "requirement" you can't assess the silliness
of the padding scheme.

-- 
Eric Sosman
esosman@ieee-dot-org.invalid
0
esosman2 (3096)
5/28/2008 12:22:59 PM
Eric Sosman <esosman@ieee-dot-org.invalid> writes:
> Keith Thompson wrote:
>> Eric Sosman <Eric.Sosman@sun.com> writes:
>>> Keith Thompson wrote:
>>>> [...] It's also legal (but silly) for the compiler
>>>> to insert padding whether it's required for alignment or not.
>>>     The ambiguity lies in "requirement."  On one popular
>>> platform, for example, a `double' can be accessed at any
>>> address divisible by four, but can be accessed more quickly
>>> if the address is also divisible by eight.  Should the
>>> alignment "requirement" be taken as four or as eight?
>> Could be either.  My point is that the compiler is allowed to insert,
>> say, 16 bytes of padding, even if it doesn't help performance at all.
>
>     ... and my point was about the word "silly:" Until you
> can nail down "requirement" you can't assess the silliness
> of the padding scheme.

Ok, good point.

To re-state my point more precisely, a compiler is allowed to insert
padding between struct members even if doing so has no benefit
whatsoever.  (I don't know of any compilers that actually do so.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
kst-u (21963)
5/28/2008 4:13:48 PM
CBFalconer <cbfalconer@yahoo.com> writes:
> rahul wrote:
>> How is the memory allocated for structures? I need to optimize
>> the memory usage and bit fields are not doing the trick.
>> 
>> Any details about the memory allocation for the structures would
>> be a great help.
>> 
>> PS - I already have asked this in gcc group. Please refrain from
>> directing me towards other groups.
>
> If you are using gcc, then a gcc group is appropriate.  This one is
> not.  A compiler system can use any method of memory allocation it
> pleases, so long as it works.

But the C standard imposes a number of requirements on how memory is
allocated for structures (as we already discussed in this thread).

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
kst-u (21963)
5/30/2008 2:11:19 AM
Reply:
Similar Artilces:

What good optimizers are available for convex optimization problems?
What good optimizers are available for convex optimization problems? Hi all, My optimization problem is a convex one. It has tens of variables. I am currently using Matlab's "fmincon" (the constrained optimization solver), because I need to set both lower bounds and upper bounds of the variables, and also I have one equality constraint for the variables to satisfy. Because the dimension is high, the Matlab medium scale solver searches in its sub-iteration each directions along each variable. Each function evaluation takes some time. And one iteration takes about a minute...

Out of memory errors with R2006a/b and .NET Components
Dear all, I recently upgraded my VB6 and MatLab 7.0.4 COM Objects to R2006a/b and VB 2005 .NET. I have been receiving a lot of out of memory errors from my MatLab .NET Components. These used to run perfectly fine with VB6/COM Objects. My computers have plenty of memory to support these codes and they run fine inside MatLab R2006a/b. Are there any memory management changes or issues with .NET components ? Thanks, Nick, Look into the /3gb boot option for Windows XP. .net reserves large portions of virtual address space for its heap I expect that is the problem and one extra gb usable add...

openvpn memory footpring
Hi, I am trying to put openvpn into an embedded linux box. After having configured and compiled openssl and openvpn, it works fine. BUT the memory footprint ist quite large compared with the applications size and the available flash space. After omitting unnecessary features via configure and after stripping the binary still needs 1.6 MB, mostly caused by openssl components. Has anybody succeeded in minimizing openvpn space requirements? For example, I don't see how I can drop unneeded crypto ciphers -- why include DES, DES3 or AES if I only use Blowfish? TIA + regards ...

How to get the Optimization level?
We use DB2-LUW-8.2. I am doing some research on performance issues and I read about the "OPTIMIZATION LEVELS' and their impacts on Joins. How do I get the Optimization level implemented here? Can I query some system tables? Can someone help me pls ? specialdosa@gmail.com wrote: > We use DB2-LUW-8.2. > > I am doing some research on performance issues and I read about the > "OPTIMIZATION LEVELS' and their impacts on Joins. > > How do I get the Optimization level implemented here? Can I query some > system tables? Can someone help me...

referencing structure with cell array
I would like to use the function fieldnames to return the names of the elements in a structure. This works and returns the names stored in a cell array. I would then like to reference the structure using this name but this causes problems, I have tried turning the name to a char but this doesn't work either. Example: x.a=rand(100,1); x.b=rand(100,1); names=fieldnames(x); names(2) ans = 'b' x.names(2); ??? Reference to non-existent field 'names'. Thanks in advance, JPJ Use dynamic fieldnames: x.(names{2}); Pay attention to the curly braces - names(2) returns ...

optimization #57
Q is a symmetric matrix of dimension N*N and H is of N*M whereN>M "vanidevi" wrote in message <m97tda$ai6$1@newscl01ah.mathworks.com>... > Q is a symmetric matrix of dimension N*N and H is of N*M whereN>M The solution is given in the section 2. Preliminaries under http://www-users.cs.umn.edu/~saad/PDF/umsi-2009-31.pdf Matlab's "eig" or "eigs" will help to determine H. Best wishes Torsten. "Torsten" wrote in message <m97vs3$frp$1@newscl01ah.mathworks.com>... > "vanidevi" wrote in message <m97tda$...

[ace-users] Re: Memory leak, new(UNINT) in TAO(1.2.1) ACE (5.2.1) ?
Hi Ludovic, >> we face a memory leak detected by rationnal purify, using a server in >> tao 1.2.1 and ace 5.2.1 : new(UINT). To ensure that we have proper version/platform/compiler information, please make sure you fill out the appropriate problem report form (PRF), which is in $ACE_ROOT/PROBLEM-REPORT-FORM $TAO_ROOT/PROBLEM-REPORT-FORM or in $ACE_ROOT/BUG-REPORT-FORM $TAO_ROOT/BUG-REPORT-FORM in older versions of ACE+TAO. Make sure to include this information when asking any questions about ACE+TAO since otherwise we have to "guess" what version...

Query Optimization #2
I am learning SQL (trial by fire) and have a question regarding a query optimization. Lets say I have three tables 'project', 'notes' & 'reminder'. Key on 'project' is 'proj_id'. The other two tables reference this key as 'notes' contains note entries on a given project and 'reminder' tracks todo type and due dates. select count(a.proj_id) from project a where a.stat_cd = 'CLOSED' and exists ( select b.proj_id from reminder b where b.rem_type = 'LAST' and a.proj_id = b.pro...

Pre-allocating a structure array
I have the following code: for k = 1 : N S(k).field1 = {some expression here}; S(k).field2 = {another expression here}; end As you can see, I have a structure growing in a for-loop. When optimising, the first step is generally to pre-allocate the memory for the growing variable. I can pre-allocate a structure: S = struct('field1', {}, 'field2', {}); But I don't know how to pre-allocate memory for an array structure. Any ideas? In article <ef5c3ba.-1@webcrossing.raydaftYaTP>, broossien@gmail.com says... > I have the following cod...

Looking for Optimization
hiya I'd like to optimize a code snippet I wrote: ------------------------------------------------------------------------ while ($Girl = each($Girls)){ $AttGirl = "Attitude$Girl[value]"; if ($$AttGirl && ("-" != $$AttGirl)) $query .= " AND (swimsuits.attitude_" . strtolower($Girl[value]) . " = '" . $$AttGirl . "')"; } ------------------------------------------------------------------------ It would be quite cool if I could drop the second line. But I don't know how to tackle this. $Girls is a simple array: ...

Interesting list() un-optimization
I stumbled upon an interesting bit of trivia concerning lists and list comprehensions today. We use mongoengine as a database model layer. A mongoengine query returns an iterable object called a QuerySet. The "obvious" way to create a list of the query results would be: my_objects = list(my_query_set) and, indeed, that works. But, then I found this code: my_objects = [obj for obj in my_query_set] which seemed a bit silly. I called over the guy who wrote it and asked him why he didn't just write it using list(). I was astounded when it turned o...

Re: macro structure #17 1554957
Ya, I think the question should be - Are there any advantages to Structure 2? The disadvantages are that it is harder to read and misleading. There is a global name space for all macros. Hence the name A is not hidden by putting the macro definition inside a macro, consequently it is somewhat misleading. All of this assumes A has no use independent of MAIN. If otherwise, then Structure 2 has the very great disadvantage that MAIN must be executed in order to make A available. I once had a student who submitted a program with the sub macro, A, defined 7 times in MAIN. It turned out that ...

WiMax Solutions has strengthened its organizational structure and established ... WiMax Solutions is devoted in the sales and promotions of prestigious ...
WiMax Solutions has strengthened its organizational structure and established ... WiMax Solutions is devoted in the sales and promotions of prestigious ... www.computersandnet.blogspot.com ...

optimize code 114946
hi.. I have this code, and i want optimize it.. any suggestion? thank you in advance. clear all; File=input('Ficheiro: ','s'); fid=fopen(File,'rt'); %modo texto - elimina o CR à partida A=fread(fid);%,'ubit1'); Comp=length(A); Simb=[]; Ocorr=[]; for i=1:Comp %length(Ocorr)+1 if isempty(Simb) Simb(1)=A(i,1); Ocorr(1)=1; else j=length(Simb); while j~=0 if A(i,1)==Simb(j) break; end j=j-1; end if j==0 ...

is it a multiobjective optimization or just a normal constrait Optimization problem?
Hello all: I want to optimize a RMS value of an Simulink model,the model will run for about 150 seconds.but is it a multiobjective optimization or just a normal constrait Optimization problem?and please tell me why. i think it's a multiobjective one.and by using the Simulink Response Optimization,it can work,that is,i'm sure the Simulink model is right,but the SRO use the Simplex search and pattern search methods,and the multiobjective optimization in Matlab seems not use these ones... Thank you for your replies!! ...

My code is way to slow.. How can I optimize!?
Dear All, This is my first post here. I was desperately looking for info on the web on optimizing IDL code, and came across this group. Looks like you might be able to help me.. For the past 3 years I have been working with IDL to get some basic processing done for my phd work. Now I have been working on processing some signals from a fieldspectrometer, using a bootstrapping routine. I was wondering how I can optimize this code, as the current code takes over a day for one run to finish. Is it possible to post some code on this forum? The code is quite long, and I'd rather put it as a d...

structure problem
Hi, I am newbie to c programming. Currently I try to learn how to use structure. So I create a structure named process and try to store pointer of previous process as well as next. However, I encounter a problem. The problem is - it seems the declaration of structure current_process is not the previous one I want, but the current process. What mistakes do I make in my programme? I appreciate any suggestion Below is my source code: ========== source code BEG ========== #include <stdio.h> #include <string.h> struct process{ char name[10]; struct process *prev; struct process ...

constrained optimization and optimization toolbox
Hi, I am trying to use fmincon for a constrained optimization problem, where the objective function is expensive to evaluate. The objective function and constraint function both involve solving the same boundary value problem. Is there a way to pass information between the objective function and the constraint function, so that I do not need to solve the boundary value problem twice? Thanks, Joe Joe Tien wrote: > Hi, > > I am trying to use fmincon for a constrained optimization problem, > where the objective function is expensive to evaluate. The objective > function and con...

Portfolio Optimization
Hi! I am trying to run a portfolio optimizer in Mathematica. That is, minimising the variance of a portfolio of assets. (* Variance Covariance Matrix *) Covariants = {{0.000572843, 0.000223023, 0.000109176}, {0.000223023, 0.000387437, 0.0000987402}, {0.000109176, 0.0000987402, 0.007320276}} (* Asset Weights Vector*) weights = Transpose[{{w1}, {w2}, {w3}}] (* Optimize Portfolio Variance*) NMinimize[{weights.Covariants.Transpose[weights], w1 + w2 + w3 == 1}, {w1, w2, w3}] The output Mathematica throws is as follows: *NMinimize::nnum: "The function value {{0.00...

OutOf Memory exception under Eclipse when using relatively small amount of heap
Hi I've tried an experimental app under Eclipse, that parses / transforms a large (96Mb) xml file using the java XSLT library DOM parser and then tried the SAX parser. The program runs fine with smaller XML input files but exits with OutOfMemory with the large input file. It seemed odd to me that I would get an out of memory because I'm set up with quite a bit of physical memory. My setup is: WinXP Pro 768 Mb Ram Eclipse -vmargs -Xmx1628M (biggest I can set it for, and still have it load) jvm 1.4.2_11 WinXP Virtual memory setup: Min 1149Mb Max 4095 (also tried "Let system man...

Optimization level in db2?
Dear All Db2 version: 8.1 OS: Windows I have 2 questions: 1) What is the optimizer which db2 uses, rule based or cost based? If any one can clear out the difference between the two it will be a great help. 2) I have an Oracle database which I have ported to db2. Now suppose after 2 months oracle database has fresh data and I need to ensure that the data in db2 database is in sync with this. How can I do this? Any help will be greatly appreciated Warm regards, Praveen Pandey "Praveen_db2" <er_praveen278@hotmail.com> wrote in message news:ef2d464443...

why start memories vary among lisp implementations?
why start memories vary among lisp implementations? why clisp has 5mb while ccl 25 mb sbcl 45 mb? i have one clue ccl and sbcl have been written in lisp itself. is its possible to make lisp implementation implemented in lisp itself and have small memory footprint like implemented in C lang? "Faruk S. Can" <farukscan@gmail.com> writes: > why start memories vary among lisp implementations? > why clisp has 5mb while ccl 25 mb sbcl 45 mb? > i have one clue ccl and sbcl have been written in lisp itself. > > is its possible to make lisp implementation imp...

Memory Trouble (Structures and malloc)
#include <stdio.h> #include <stdlib.h> typedef struct _oneLine { int ntoks; char **lns; }OneLine; typedef struct _codeArray { int argc; OneLine **args; }CodeArray; int main(int argc, char *argv[]) { int i, ii, iii; /* codeArray[10] */ CodeArray *c = malloc(10 * sizeof(CodeArray) ); /* CodeArray[10].args[10][10] */ for (i = 0; i < 10; ++i) { c[i].args = malloc ( 10 * sizeof(OneLine) ); for(ii = 0; ii < 10; ++ii) c[i].args[ii] = malloc ( 10 * sizeof(OneLine) ); } /* CodeArray[10...

Continuous Gray code optimization
I recently found a paper about a really simple but effective numerical optimization algorithm based on extending the idea of Gray codes to the continuous domain. I've put the paper and some sample code here: http://code.google.com/p/lemontree/downloads/list I am working on improving the algorithm at the moment. I have a few ideas! Sean O'Connor ...

Optimize divide 3
Hi all, This night I try to use arithmetic shift to optimize divide 3, such as (a / 3), but I can't work out a way to transform it to a shift operation. Any thing can get me out of this problem? Thanks a lot. Binary Chen In article <1127138576.329769.311590@g47g2000cwa.googlegroups.com>, "Binary" <binary.chen@gmail.com> wrote: > This night I try to use arithmetic shift to optimize divide 3, such as > (a / 3), but I can't work out a way to transform it to a shift > operation. > > Any thing can get me out of this problem? ...