IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C++/CLI Discussion :

Gestion de la memoire


Sujet :

C++/CLI

  1. #1
    Membre habitué Avatar de deeal
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Novembre 2004
    Messages : 218
    Points : 169
    Points
    169
    Par défaut Gestion de la memoire
    Bonjour a tous
    je voudrais ecrire une petite portion de code dans mon application pour connaitre ce qui se passe cote allocation et tout, du genre combien de memoire a ete allouee, combien la managed heap contient, la CRT heap
    j'ai regarde dans System:iagnostics mais je ne vois pas
    quelqu'un aurait une idee?
    Merci

  2. #2
    Rédacteur
    Avatar de nico-pyright(c)
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    6 414
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 6 414
    Points : 16 075
    Points
    16 075
    Par défaut
    faut que ce soit toi qui fasse le code ou bien tu veux utiliser un outil du genre CLR profiler

  3. #3
    Membre habitué Avatar de deeal
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Novembre 2004
    Messages : 218
    Points : 169
    Points
    169
    Par défaut
    merci nico je vais l'esssayer
    en fait mon probleme c'est que j'ai splash screen et j'ai mit un Breakpoint just apres le chargement de ce dernier et je ne vous dis pas
    j'ai deja 250M de memoire prise
    que;qu'un aurait recontre le meme probleme?
    Merci

  4. #4
    Rédacteur
    Avatar de nico-pyright(c)
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    6 414
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 6 414
    Points : 16 075
    Points
    16 075
    Par défaut
    tu as fait des allocations avant ? CRT ou CLR ?

  5. #5
    Membre habitué Avatar de deeal
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Novembre 2004
    Messages : 218
    Points : 169
    Points
    169
    Par défaut
    j'ai fait les deux, le projet consiste en allocations CLR et CRT

  6. #6
    Rédacteur
    Avatar de nico-pyright(c)
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    6 414
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 6 414
    Points : 16 075
    Points
    16 075
    Par défaut
    ca peut etre normal alors si tu effectues pas mal d'allocations

  7. #7
    Membre habitué Avatar de deeal
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Novembre 2004
    Messages : 218
    Points : 169
    Points
    169
    Par défaut
    le probleme c'est que j'ai traque les callstack et tout, mais a l'appel du driver pour la carte graphie (DirectX) il y'a une allocation de 250M, je crois que le probleme vient de la carte graphique en fin de compte, j'ai essaie l'application sur une autre machine et le probleme ne se pose plus
    Merci

  8. #8
    Membre habitué Avatar de deeal
    Profil pro
    Inscrit en
    Novembre 2004
    Messages
    218
    Détails du profil
    Informations personnelles :
    Âge : 40
    Localisation : France

    Informations forums :
    Inscription : Novembre 2004
    Messages : 218
    Points : 169
    Points
    169
    Par défaut
    juste si quelqu'un serait interesse de connaitre combien ses DL ou son executable prend comme memoire
    j'ai fait ce petit bout de code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
     
    #include "stdafx.h"
    #include "windows.h"
    #include "iostream"
    #include "Psapi.h"
     
    #pragma comment(lib,"Psapi.lib")
    using namespace std;
     
     
     
    int _tmain(int argc, _TCHAR* argv[])
     
    {
     
    			cout << "Parcourir la memoire virtuelle" << endl;
    			cout << "==============================" << endl;
    			 SIZE_T address = 0;
    			 SIZE_T returnVal = -1;
    			 LPCVOID inputAddress = 0;
    			 HANDLE currProcess = GetCurrentProcess();
    			 MEMORY_BASIC_INFORMATION memInfoStruct;
    			 ZeroMemory(&memInfoStruct, sizeof(MEMORY_BASIC_INFORMATION));
     			 // VirtualQueryEx retourne 0 avec une adress du kernel
    			 // commencer la lecture de la memoire
    			 while(returnVal != 0)
    			 {
    							inputAddress = (LPCVOID)address;
    							returnVal = VirtualQueryEx(currProcess, inputAddress, &memInfoStruct, sizeof(MEMORY_BASIC_INFORMATION));
    							cout << address << "\t" << memInfoStruct.RegionSize  << "\t";
    							// State
    							// MEM_COMMIT - 0x1000
    							// MEM_FREE - 0x10000
    							// MEM_RESERVE - 0x2000
    							if(memInfoStruct.State == 0x1000 )
    							{
    										cout << "MEM_COMMIT\t";
    							}
    							else if( memInfoStruct.State == 0x10000 )
    							{
    										cout << "MEM_FREE\t";
    							}
    						 else if( memInfoStruct.State == 0x2000 )
    							{
    										cout << "MEM_RESERVE\t";
    							}
    							// Protect
    							// PAGE_EXECUTE - 0x10
    							// PAGE_EXECUTE_READ - 0x20
    							// PAGE_EXECUTE_READWRITE - 0x40
    							// PAGE_EXECUTE_WRITECOPY - 0x80
    							// PAGE_NOACCESS - 0x01
    							// PAGE_READONLY - 0x02
    							// PAGE_READWRITE - 0x04
    							// PAGE_WRITECOPY - 0x08
    							// PAGE_GUARD - 0x100
    							// PAGE_NOCACHE - 0x200
    							// PAGE_WRITECOMBINE - 0x400
    							cout << memInfoStruct.AllocationProtect << "\t";
    							cout << memInfoStruct.Protect << "\t";
    							// TYPE 
    							// MEM_IMAGE - 0x1000000
    							// MEM_MAPPED - 0x40000
    							// MEM_PRIVATE - 0x20000
    							if(memInfoStruct.Type == 0x1000000 )
    							{
    										 cout << "MEM_IMAGE\t";
    										 _TCHAR szProcessName[MAX_PATH] = _T("<unknown>");
    										 HMODULE modHandle = (HMODULE)memInfoStruct.AllocationBase;
    										 GetModuleBaseName(currProcess, modHandle, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
    										 _tprintf( _T("%s"), szProcessName );
    							}
    							else if( memInfoStruct.Type == 0x40000 )
    							{
    										 cout << "MEM_MAPPED\t";
                         _TCHAR szProcessName[MAX_PATH] = _T("<unknown>");
                         HMODULE modHandle = (HMODULE)memInfoStruct.AllocationBase;
                         GetModuleBaseName(currProcess, modHandle, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
                         _tprintf( _T("%s"), szProcessName );
    							}
    							else if( memInfoStruct.Type == 0x20000 )
    							{
    										 cout << "MEM_PRIVATE\t";
    							}
    							cout << endl;
      						address = address + memInfoStruct.RegionSize;
     
     
    			 }
           char c;
           cin>>c;
    			 return 0;
    }
    et desole c'est du pur C++

  9. #9
    Expert éminent sénior
    Avatar de Médinoc
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Septembre 2005
    Messages
    27 369
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2005
    Messages : 27 369
    Points : 41 518
    Points
    41 518
    Par défaut
    Le même code, réindenté:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    #include "stdafx.h"
    #include "windows.h"
    #include "iostream"
    #include "Psapi.h"
     
    #pragma comment(lib,"Psapi.lib")
    using namespace std;
     
    int _tmain(int argc, _TCHAR* argv[])
    {
    	cout << "Parcourir la memoire virtuelle" << endl;
    	cout << "==============================" << endl;
    	SIZE_T address = 0;
    	SIZE_T returnVal = -1;
    	LPCVOID inputAddress = 0;
    	HANDLE currProcess = GetCurrentProcess();
    	MEMORY_BASIC_INFORMATION memInfoStruct;
    	ZeroMemory(&memInfoStruct, sizeof(MEMORY_BASIC_INFORMATION));
    	// VirtualQueryEx retourne 0 avec une adress du kernel
    	// commencer la lecture de la memoire
    	while(returnVal != 0)
    	{
    		inputAddress = (LPCVOID)address;
    		returnVal = VirtualQueryEx(currProcess, inputAddress, &memInfoStruct, sizeof(MEMORY_BASIC_INFORMATION));
    		cout << address << "\t" << memInfoStruct.RegionSize  << "\t";
    		// State
    		// MEM_COMMIT - 0x1000
    		// MEM_FREE - 0x10000
    		// MEM_RESERVE - 0x2000
    		if(memInfoStruct.State == 0x1000 )
    		{
    			cout << "MEM_COMMIT\t";
    		}
    		else if( memInfoStruct.State == 0x10000 )
    		{
    			cout << "MEM_FREE\t";
    		}
    		else if( memInfoStruct.State == 0x2000 )
    		{
    			cout << "MEM_RESERVE\t";
    		}
    		// Protect
    		// PAGE_EXECUTE - 0x10
    		// PAGE_EXECUTE_READ - 0x20
    		// PAGE_EXECUTE_READWRITE - 0x40
    		// PAGE_EXECUTE_WRITECOPY - 0x80
    		// PAGE_NOACCESS - 0x01
    		// PAGE_READONLY - 0x02
    		// PAGE_READWRITE - 0x04
    		// PAGE_WRITECOPY - 0x08
    		// PAGE_GUARD - 0x100
    		// PAGE_NOCACHE - 0x200
    		// PAGE_WRITECOMBINE - 0x400
    		cout << memInfoStruct.AllocationProtect << "\t";
    		cout << memInfoStruct.Protect << "\t";
    		// TYPE 
    		// MEM_IMAGE - 0x1000000
    		// MEM_MAPPED - 0x40000
    		// MEM_PRIVATE - 0x20000
    		if(memInfoStruct.Type == 0x1000000 )
    		{
    			cout << "MEM_IMAGE\t";
    			_TCHAR szProcessName[MAX_PATH] = _T("<unknown>");
    			HMODULE modHandle = (HMODULE)memInfoStruct.AllocationBase;
    			GetModuleBaseName(currProcess, modHandle, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
    			_tprintf( _T("%s"), szProcessName );
    		}
    		else if( memInfoStruct.Type == 0x40000 )
    		{
    			cout << "MEM_MAPPED\t";
    			_TCHAR szProcessName[MAX_PATH] = _T("<unknown>");
    			HMODULE modHandle = (HMODULE)memInfoStruct.AllocationBase;
    			GetModuleBaseName(currProcess, modHandle, szProcessName, sizeof(szProcessName)/sizeof(TCHAR) );
    			_tprintf( _T("%s"), szProcessName );
    		}
    		else if( memInfoStruct.Type == 0x20000 )
    		{
    			cout << "MEM_PRIVATE\t";
    		}
    		cout << endl;
    		address = address + memInfoStruct.RegionSize;
    	}
    	char c;
    	cin>>c;
    	return 0;
    }
    SVP, pas de questions techniques par MP. Surtout si je ne vous ai jamais parlé avant.

    "Aw, come on, who would be so stupid as to insert a cast to make an error go away without actually fixing the error?"
    Apparently everyone.
    -- Raymond Chen.
    Traduction obligatoire: "Oh, voyons, qui serait assez stupide pour mettre un cast pour faire disparaitre un message d'erreur sans vraiment corriger l'erreur?" - Apparemment, tout le monde. -- Raymond Chen.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 3
    Dernier message: 13/12/2006, 10h04
  2. Gestion de la memoire central d'un PC
    Par Bass_Room dans le forum C
    Réponses: 7
    Dernier message: 22/10/2006, 15h02
  3. gestion de la memoire en java
    Par jojob dans le forum Langage
    Réponses: 15
    Dernier message: 16/10/2006, 17h04
  4. Gestion de la mémoire.
    Par nicolas_faf dans le forum GTK+ avec C & C++
    Réponses: 4
    Dernier message: 27/03/2006, 16h58
  5. [JVM]Gestion de la mémoire
    Par Crypt dans le forum Général Java
    Réponses: 20
    Dernier message: 31/12/2005, 14h33

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo