|
Boost : |
From: hankel_o_fung_at_[hidden]
Date: 2001-03-14 03:45:43
[Sorry if I go off topic - Hankel]
--- In boost_at_y..., Dan Nuffer <dnuffer_at_c...> wrote:
> hankel_o_fung_at_y... wrote:
> > Perhaps. However, although VC++'s is unable to allocate a big
> > (...2MB?!) chunk of memory:
> >
> > int main() {double array[512][512];} // fails to allocate 2MB
>
> This fails because you don't have enough stack space. I think the
> default for VC++ is 1 MB (don't quote me on that; it's been a while
> since I used VC++) There is an option somewhere in VC++ that
> allows you to increase the amount of stack your program will get.
Thanks, Dan, you are right. There's an option for increasing the
heap size as well.
The above is perhaps a wrong example, coz in my original BGL problem,
memory was allocated on heap. As another poster pointed out, I
might need around 70-80MB of memory in that problem. Since my NT
box has 384MB RAM, I didn't know why the program didn't work.
It turns out that the program did work. I just haven't waited for
long enough. From NT Task Manager, I learnt that the program had
used up almost 430MB of memory!!! After memory allocation, it took
tens of seconds to do some cleanup job and then terminated.
So the program did work, yet I still don't know why there's such
a huge gap between the actual and the estimated memory usages. And
another strange thing: if I use float instead of double for edge
weight, the memory usage is even higher (almost 670MB) and the
program takes even longer (several minutes) to terminate.
Hankel
using namespace std;
using namespace boost;
typedef adjacency_list< listS, vecS, undirectedS,
no_property, property<edge_weight_t, double> > Graph;
int const N = 512;
int index(int i, int j) { return i*N + j; }
int main()
{
Graph G(N*N);
for (int i=0; i<N-1; ++i)
{
cout << i << flush;
for (int j=0; j<N; ++j)
{
int begin = (j-8 < 0 ? 0 : j-8);
int end = (j+8+1 > N ? N : j+8+1);
for (int k=begin; k<end; ++k)
put(edge_weight, G,
add_edge(index(i,j), index(i+1,k), G).first, 1.0);
// this is simplified -- in my original program G
// hasn't a regular structure
}
cout << endl;
}
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk