[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] igraph_get_all_shortest_paths memory problem
From: |
Guilherme Ferraz de Arruda |
Subject: |
Re: [igraph] igraph_get_all_shortest_paths memory problem |
Date: |
Wed, 2 Mar 2011 02:17:32 -0300 |
Sorry again, i forgot to destroy the graph at each iteration.
But the problem persists.
I've tryed to comment the line with the function
igraph_get_all_shortest_paths() and it "fixed" the problem of memory,
this indicates that there are a memory problem with this function,
dont you think?
Thanks for all.
2011/3/2 Guilherme Ferraz de Arruda <address@hidden>:
> I send the wrong main.cpp, i forgot to delete the S matrix.
>
> The memory continues to growing.
>
> Thanks for the help.
>
> Guilherme.
>
> 2011/3/1 Guilherme Ferraz de Arruda <address@hidden>:
>> I have made a little project that shows my problem.
>>
>> Thanks for all.
>>
>> Guilherme.
>>
>>
>> 2011/3/1 Gábor Csárdi <address@hidden>:
>>> Hi,
>>>
>>> please send a program that we can actually compile and run, and it
>>> reproduces your problem.
>>>
>>> Thanks,
>>> Gabor
>>>
>>> On Tue, Mar 1, 2011 at 8:56 PM, Guilherme Ferraz de Arruda
>>> <address@hidden> wrote:
>>>> Hi,
>>>>
>>>> I have a problem with memory allocation and free. My program memory is
>>>> increasing.
>>>> My code:
>>>>
>>>> long int GetValue(igraph_vector_t *v, long int i){
>>>> return (long int) VECTOR(*v)[i];
>>>> }
>>>>
>>>> long int GetLastValue(igraph_vector_t *v){
>>>> return (long int) VECTOR(*v)[igraph_vector_size(v)-1];
>>>> }
>>>>
>>>> double Ppib(igraph_t* g, igraph_vector_t *v){
>>>> long int ki = 0, kj = 0;
>>>> igraph_vector_t res0;
>>>> igraph_vector_init(&res0, 0);
>>>>
>>>> double acc = 1.0;
>>>>
>>>> igraph_degree(g, &res0,
>>>> igraph_vss_1((igraph_integer_t)VECTOR(*v)[0]), IGRAPH_ALL,
>>>> IGRAPH_NO_LOOPS);
>>>> ki = (double)VECTOR(res0)[0];
>>>> igraph_vector_clear(&res0);
>>>>
>>>> long int l = 0;
>>>> for(l=1; l<igraph_vector_size(v) - 1; l++){
>>>> igraph_degree(g, &res0,
>>>> igraph_vss_1((igraph_integer_t)VECTOR(*v)[l]), IGRAPH_ALL,
>>>> IGRAPH_NO_LOOPS);
>>>> kj = (double)VECTOR(res0)[0];
>>>> acc *= (double)1.0/(double)(kj - 1.0);
>>>> }
>>>>
>>>> igraph_vector_destroy(&res0);
>>>>
>>>> return acc/ki;
>>>> }
>>>>
>>>> int CreateSMatrix(igraph_t* g, double** S){
>>>> long int N = igraph_vcount(g);
>>>>
>>>> long int vertice = 0;
>>>> long int i = 0, j = 0, k = 0;
>>>>
>>>> for(vertice=0; vertice<N; vertice++){
>>>> igraph_vector_ptr_t vecs;
>>>> igraph_vector_ptr_init(&vecs, N);
>>>>
>>>> for (i=0; i<igraph_vector_ptr_size(&vecs); i++) {
>>>> VECTOR(vecs)[i] = calloc(1, sizeof(igraph_vector_t));
>>>> igraph_vector_init(VECTOR(vecs)[i], 0);
>>>> }
>>>>
>>>> igraph_get_all_shortest_paths(g, &vecs, NULL, vertice,
>>>> igraph_vss_all(), IGRAPH_ALL);
>>>>
>>>> for (k=0; k<igraph_vector_ptr_size(&vecs); k++) {
>>>> //P(p(i,b)
>>>> S[GetValue(VECTOR(vecs)[k], 0)][GetLastValue(VECTOR(vecs)[k])] +=
>>>> Ppib(g, VECTOR(vecs)[k]);
>>>>
>>>> igraph_vector_destroy(VECTOR(vecs)[k]);
>>>> free(VECTOR(vecs)[k]);
>>>> }
>>>>
>>>> igraph_vector_ptr_destroy(&vecs);
>>>>
>>>> }
>>>>
>>>> for(i=0; i<N; i++)
>>>> for(k=0; k<N; k++)
>>>> if(S[i][k] != 0.0) S[i][k] = (-1)*log2(S[i][k]);
>>>>
>>>> return 1;
>>>> }
>>>>
>>>> There is no error at compiling time and execution time.
>>>>
>>>> It's almost iqual as the igraph_get_shortest-paths.c example. I
>>>> checked it many times and couldn't find an memory problem.
>>>> Is there a trick?
>>>>
>>>> Thanks for all.
>>>>
>>>> Guilherme.
>>>>
>>>> _______________________________________________
>>>> igraph-help mailing list
>>>> address@hidden
>>>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>>>>
>>>
>>>
>>>
>>> --
>>> Gabor Csardi <address@hidden> UNIL DGM
>>>
>>
>
main.cpp
Description: Text Data
- [igraph] igraph_get_all_shortest_paths memory problem, Guilherme Ferraz de Arruda, 2011/03/01
- Re: [igraph] igraph_get_all_shortest_paths memory problem, Gábor Csárdi, 2011/03/01
- Re: [igraph] igraph_get_all_shortest_paths memory problem, Guilherme Ferraz de Arruda, 2011/03/01
- Re: [igraph] igraph_get_all_shortest_paths memory problem, Guilherme Ferraz de Arruda, 2011/03/01
- Re: [igraph] igraph_get_all_shortest_paths memory problem,
Guilherme Ferraz de Arruda <=
- Re: [igraph] igraph_get_all_shortest_paths memory problem, Tamas Nepusz, 2011/03/02
- Re: [igraph] igraph_get_all_shortest_paths memory problem, Guilherme Ferraz de Arruda, 2011/03/02
- Re: [igraph] igraph_get_all_shortest_paths memory problem, Tamas Nepusz, 2011/03/02
- Re: [igraph] igraph_get_all_shortest_paths memory problem, Guilherme Ferraz de Arruda, 2011/03/02