| View previous topic :: View next topic |
| Author |
Message |
fanny & michou Guest
|
Posted: Fri Sep 10, 2004 9:37 pm Post subject: Problème d'allocation |
|
|
Bonjour,
Je programme a deux endroits différents (voir post : "Problème avec
abs") et bienqu'a mon travail mon programme s'exécute correctement, je
suis confrontée à une erreur chez moi :
une fois le programme lancé, j'ai le message d'erreur
" terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Aborted"
Quelqu'un a-t-il une piste pour m'aider a resoudre ce problème?
C'est pas très agréable de programmer via une connexion ssh pas toujours
très rapide ;-)
Merci pour votre aide.
Fanny
|
|
| Back to top |
|
 |
Jonathan Mcdougall Guest
|
Posted: Sat Sep 11, 2004 7:49 am Post subject: Re: Problème d'allocation |
|
|
| Quote: | une fois le programme lancé, j'ai le message d'erreur
" terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
Aborted"
Quelqu'un a-t-il une piste pour m'aider a resoudre ce problème?
|
std::bad_alloc est lancé par new lorsqu'il n'y a plus de mémoire
disponible :
# include <iostream>
int main()
{
try
{
while (true)
{
int *i = new int[10000];
}
}
catch(std::bad_alloc&)
{
std::cout << "et voila" << std::endl;
}
}
Quelles genres d'opérations fais-tu avec new?
Jonathan
|
|
| Back to top |
|
 |
Pierre Maurette Guest
|
Posted: Sat Sep 11, 2004 8:04 am Post subject: Re: Problème d'allocation |
|
|
fanny & michou <fanny.michou (AT) free (DOT) fr> a écrit:
Problème d'allocation ?
http://www.caf.fr/
Bon week-end
--
Pierre
|
|
| Back to top |
|
 |
fanny & michou Guest
|
Posted: Sat Sep 11, 2004 12:47 pm Post subject: Re: Problème d'allocation |
|
|
| Quote: | # include <iostream
int main()
{
try
{
while (true)
{
int *i = new int[10000];
}
}
catch(std::bad_alloc&)
{
std::cout << "et voila" << std::endl;
}
}
Quelles genres d'opérations fais-tu avec new?
Jonathan
|
Ben je créé un nouvel objet : il bloque au moment de
créer une matrice je crois donc vector< vector .
Mais je comprends pas : ca marche a mon travail parce
qu'il y a plus de mémoire?
|
|
| Back to top |
|
 |
Jonathan Mcdougall Guest
|
Posted: Sun Sep 12, 2004 7:05 am Post subject: Re: Problème d'allocation |
|
|
fanny & michou wrote:
| Quote: |
# include <iostream
int main()
{
try
{
while (true)
{
int *i = new int[10000];
}
}
catch(std::bad_alloc&)
{
std::cout << "et voila" << std::endl;
}
}
Quelles genres d'opérations fais-tu avec new?
Ben je créé un nouvel objet : il bloque au moment de
créer une matrice je crois donc vector< vector .
|
Peux-tu montrer un peu de code? Comme std::vector utilise
habituellement new et delete, il est possible qu'il manque de mémoire à
l'interne.
| Quote: | Mais je comprends pas : ca marche a mon travail parce
qu'il y a plus de mémoire?
|
std::bad_alloc ne peut être lancé que parce que new n'a pas fonctionné.
Comme habituellement, new utilise malloc et que malloc utilise la
mémoire vive du système, une des conclusions possibles est que tu
manques de mémoire vive chez toi, mais que ça marche à ton travail.
Est-ce possible?
Jonathan
|
|
| Back to top |
|
 |
|