S
Sims
Hi,
I suspect it is an OS related question but I am not sure what the
standard say regarding freeing memory when you 'erase' a value.
lets say that I have something like...
//
//
//
struct int_array{
int_array(){
a = b = 0;
}
int a, b;
};
typedef std::vector< int_array, std::allocator< int_array >> v_int_array;
//
// I then read millions of numbers from a file.
//
I then do some operations, (with the numbers).
And, (depending on the operation I did with those numbers), add them to
some other array.
To make sure the numbers never get used twice I 'erase' them from the
'master' array.
but the memory never seem to be freed.
you might think it is not a problem but all those numbers are taking a
large chunk of memory and when I copy them to their corresponding array
I now have 2 massive arrays.
So how can I erase a number?
v_int_array *some_num = get_values();
// use a number to do some calculations...
some_num->erase( some_num->begin() + nValToErase );
// but the memory is not freed...
Many thanks
Simon
I suspect it is an OS related question but I am not sure what the
standard say regarding freeing memory when you 'erase' a value.
lets say that I have something like...
//
//
//
struct int_array{
int_array(){
a = b = 0;
}
int a, b;
};
typedef std::vector< int_array, std::allocator< int_array >> v_int_array;
//
// I then read millions of numbers from a file.
//
I then do some operations, (with the numbers).
And, (depending on the operation I did with those numbers), add them to
some other array.
To make sure the numbers never get used twice I 'erase' them from the
'master' array.
but the memory never seem to be freed.
you might think it is not a problem but all those numbers are taking a
large chunk of memory and when I copy them to their corresponding array
I now have 2 massive arrays.
So how can I erase a number?
v_int_array *some_num = get_values();
// use a number to do some calculations...
some_num->erase( some_num->begin() + nValToErase );
// but the memory is not freed...
Many thanks
Simon