Autre Fuite de mémoire

Inscrit
10 Mai 2015
Messages
357
Reactions
55
#1
Bonjour tout le monde,

Ces derniers temps, j'essaie de faire un lecteur de script lua en Vb.net, tout fonctionne parfaitement sauf qu'au bout d'un moment, la mémoire augmente assez vite. J'ai isolé le problème, et il me suffit de faire un dispose, sauf que si je fais un dispose du script lua, les variables de l'utilisateur qui à fait son script sont réinitialisées.

J'ai réfléchis longuement au problème mais j'ai pas d'idée, j'ai même fait un programme pour faire mes tests sur la consommation. Ce que je comprends pas c'est que la mémoire augmente hyper vite alors que je ne fais que récupérer une table à partir d'une fonction en Lua voici le code du script

Code:
MIN_MONSTERS = 1 -- Il va combattre seulement
MAX_MONSTERS = 8 -- les groupes de 1 a 3 monstres
CHECK = false
function move()
CHECK = true
  return {
    { map = "0,-22", fight = true, path = "right|bottom" },
    { map = "1,-22", fight = true, path = "right|left|bottom" },
    { map = "2,-22", fight = true, path = "right|left|bottom" },
    { map = "3,-22", fight = true, path = "right|left|bottom" },
    { map = "4,-22", fight = true, path = "right|left|bottom" },
    { map = "5,-22", fight = true, path = "left|bottom" },
    { map = "-1,-21", fight = true, path = "right|bottom" },
    { map = "0,-21", fight = true, path = "right|left|bottom|top" },
    { map = "1,-21", fight = true, path = "right|left|bottom|top" },
    { map = "2,-21", fight = true, path = "right|left|bottom|top" },
    { map = "3,-21", fight = true, path = "right|left|bottom|top" },
    { map = "4,-21", fight = true, path = "right|left|bottom|top" },
    { map = "5,-21", fight = true, path = "right|left|bottom|top" },
    { map = "6,-21", fight = true, path = "right|left|bottom" },
    { map = "7,-21", fight = true, path = "left|bottom" },
    { map = "-1,-20", fight = true, path = "right|bottom|top" },
    { map = "0,-20", fight = true, path = "right|left|bottom|top" },
    { map = "1,-20", fight = true, path = "right|left|bottom|top" },
    { map = "2,-20", fight = true, path = "right|left|bottom|top" },
    { map = "3,-20", fight = true, path = "right|left|bottom|top" },
    { map = "4,-20", fight = true, path = "right|left|bottom|top" },
    { map = "5,-20", fight = true, path = "right|left|bottom|top" },
    { map = "6,-20", fight = true, path = "right|left|bottom|top" },
    { map = "7,-20", fight = true, path = "left|bottom|top" },
    { map = "-1,-19", fight = true, path = "right|bottom|top" },
    { map = "0,-19", fight = true, path = "right|left|bottom|top" },
    { map = "1,-19", fight = true, path = "right|left|bottom|top" },
    { map = "2,-19", fight = true, path = "right|left|bottom|top" },
    { map = "3,-19", fight = true, path = "right|left|bottom|top" },
    { map = "4,-19", fight = true, path = "right|left|bottom|top" },
    { map = "5,-19", fight = true, path = "right|left|bottom|top" },
    { map = "6,-19", fight = true, path = "right|left|bottom|top" },
    { map = "7,-19", fight = true, path = "left|bottom|top" },
    { map = "-1,-18", fight = true, path = "right|bottom|top" },
    { map = "0,-18", fight = true, path = "right|left|bottom|top" },
    { map = "1,-18", fight = true, path = "right|left|bottom|top" },
    { map = "2,-18", fight = true, path = "right|left|bottom|top" },
    { map = "3,-18", fight = true, path = "right|left|bottom|top" },
    { map = "4,-18", fight = true, path = "right|left|bottom|top" },
    { map = "5,-18", fight = true, path = "right|left|bottom|top" },
    { map = "6,-18", fight = true, path = "right|left|bottom|top" },
    { map = "7,-18", fight = true, path = "left|bottom|top" },
    { map = "-1,-17", fight = true, path = "right|bottom|top" },
    { map = "0,-17", fight = true, path = "right|left|bottom|top" },
    { map = "1,-17", fight = false, path = "right|left|bottom|top" },
    { map = "2,-17", fight = true, path = "right|left|bottom|top" },
    { map = "3,-17", fight = true, path = "right|left|bottom|top" },
    { map = "4,-17", fight = true, path = "right|left|bottom|top" },
    { map = "5,-17", fight = true, path = "right|left|bottom|top" },
    { map = "6,-17", fight = true, path = "right|left|bottom|top" },
    { map = "7,-17", fight = true, path = "left|bottom|top" },
    { map = "-1,-16", fight = true, path = "right|bottom|top" },
    { map = "0,-16", fight = true, path = "right|left|bottom|top" },
    { map = "1,-16", fight = true, path = "right|left|bottom|top" },
    { map = "2,-16", fight = true, path = "right|left|bottom|top" },
    { map = "3,-16", fight = true, path = "right|left|bottom|top" },
    { map = "5,-16", fight = true, path = "right|left|bottom|top" },
    { map = "6,-16", fight = true, path = "right|left|bottom|top" },
    { map = "7,-16", fight = true, path = "left|bottom|top" },
    { map = "-1,-15", fight = true, path = "right|bottom|top" },
    { map = "0,-15", fight = true, path = "right|left|bottom|top" },
    { map = "1,-15", fight = true, path = "right|left|bottom|top" },
    { map = "2,-15", fight = true, path = "right|left|bottom|top" },
    { map = "3,-15", fight = true, path = "right|left|bottom|top" },
    { map = "4,-15", fight = true, path = "left|top" },
    { map = "5,-15", fight = true, path = "right|left|top" },
    { map = "6,-15", fight = true, path = "right|left|top" },
    { map = "7,-15", fight = true, path = "left|top" },
    { map = "-1,-14", fight = true, path = "right|top" },
    { map = "0,-14", fight = true, path = "right|left|top" },
    { map = "1,-14", fight = true, path = "top|right" },
    { map = "2,-14", fight = true, path = "top|right|left" },
    { map = "3,-14", fight = true, path = "top|right|left" },
    { map = "4,-14", fight = true, path = "top|left" },
    { map = "-2,-14", path = "right" },
    { map = "-1,-13", path = "top" },
    { map = "84674566", path = "top" },-- Map exterieure de la banque
    { map = "83887104", path = "396" },-- Map interieur de la banque
  }
end
function bank ()
    return {
    { map = "0,-22",path = "right" },
    { map = "1,-22",  path  = "right" },
    { map = "2,-22",  path  = "right" },
    { map = "3,-22",  path  = "right" },
    { map = "4,-22",  path  = "bottom" },
    { map = "5,-22",  path  = "left" },
    { map = "-1,-21",  path  = "right" },
    { map = "0,-21",  path = "right" },
    { map = "1,-21",  path = "right" },
    { map = "2,-21",  path = "right" },
    { map = "3,-21",  path = "right" },
    { map = "4,-21",  path = "bottom" },
    { map = "5,-21",  path = "left" },
    { map = "6,-21",  path = "left" },
    { map = "7,-21",  path = "left" },
    { map = "-1,-20",  path = "right" },
    { map = "0,-20",  path = "right" },
    { map = "1,-20",  path = "right" },
    { map = "2,-20",  path = "right" },
    { map = "3,-20",  path = "right" },
    { map = "4,-20",  path = "bottom" },
    { map = "5,-20",  path = "left" },
    { map = "6,-20",  path = "left" },
    { map = "7,-20",  path = "left" },
    { map = "-1,-19",  path = "right" },
    { map = "0,-19",  path = "right" },
    { map = "1,-19",  path = "right" },
    { map = "2,-19",  path = "right" },
    { map = "3,-19",  path = "right" },
    { map = "4,-19",  path = "bottom" },
    { map = "5,-19",  path = "left" },
    { map = "6,-19",  path = "left" },
    { map = "7,-19",  path = "left" },
    { map = "-1,-18",  path = "right" },
    { map = "0,-18",  path = "right" },
    { map = "1,-18",  path = "right" },
    { map = "2,-18",  path = "right" },
    { map = "3,-18",  path = "right" },
    { map = "4,-18",  path = "bottom" },
    { map = "5,-18",  path = "left" },
    { map = "6,-18",  path = "left" },
    { map = "7,-18",  path = "left" },
    { map = "-1,-17",  path = "right" },
    { map = "0,-17",  path = "right" },
    { map = "1,-17", path = "right" },
    { map = "2,-17",  path = "right" },
    { map = "3,-17",  path = "right" },
    { map = "4,-17",  path = "bottom" },
    { map = "5,-17",  path = "left" },
    { map = "6,-17",  path = "left" },
    { map = "7,-17",  path = "left" },
    { map = "-1,-16",  path = "right" },
    { map = "0,-16",  path = "right" },
    { map = "1,-16",  path = "right" },
    { map = "2,-16",  path = "right" },
    { map = "3,-16",  path = "right" },
    { map = "5,-16",  path = "left" },
    { map = "6,-16",  path = "left" },
    { map = "7,-16",  path = "left" },
    { map = "-1,-15",  path = "right" },
    { map = "0,-15",  path = "right" },
    { map = "1,-15",  path = "right" },
    { map = "2,-15",  path = "right" },
    { map = "3,-15",  path = "right" },
    { map = "4,-15",  path = "top" },
    { map = "5,-15",  path = "left" },
    { map = "6,-15",  path = "left" },
    { map = "7,-15",  path = "left" },
    { map = "-1,-14",  path = "right" },
    { map = "0,-14",  path = "right" },
    { map = "1,-14",  path = "right" },
    { map = "2,-14",  path = "right" },
    { map = "3,-14",  path = "right" },
    { map = "4,-14",  path = "top" },
    { map = "-2,-14", path = "right" },
    { map = "-1,-13", path = "top" },
    { map = "84674566", door = "303" }, -- Map exterieure de la banque
    { map = "83887104", npcBank = true }, -- Parle au pnj et vide son inventaire en banque
    }
end
Voici le code que j'effectue : (boucle infinie pour faire mes tests)


C'est le move.Call(0) qui fait augmenter énormément la mémoire vive, donc enfaite, ce qu'il faudrait c'est une fonction qui fait un dispose mais pas de tout si vous voyez ce que je veux dire.
 

neross

Membre Actif
Inscrit
20 Decembre 2014
Messages
150
Reactions
0
#2
En faite une variable de désalloue qu'a la fin d'une fonction si tu ne la stock pas en globale. :)
Du coup a chaque foi que tu rentre dans ta fonction de thread ça rajoute a nouveau les variables. Comme si c’était des nouvelles.

Test ça :

Code:
Public Sub threadScript()

Dim move = newscript.GetFunction("move")
Dim Moveok = Move.Call(0)
....
....
....

move = null
Moveok = null

...
...
...

threadScript()

End Sub
 
Inscrit
10 Mai 2015
Messages
357
Reactions
55
#3
j'ai déjà essayé malheureusement ça change strictement rien. toute la "Ram" se trouve dans le newscript.

Voici comment j'initialise newscript :

 
Inscrit
18 Février 2015
Messages
228
Reactions
7
#4
Code:
using (Lua lua = New Lua())
           {
               lua.LoadCLRPackage()
              lua.DoFile(_script)
           }
Et en faisant ça ça ne change rien ?
 
Inscrit
10 Mai 2015
Messages
357
Reactions
55
#5
Enfaite ça change rien, c'est comme si tu faisais un dispose en sortant de du end using
 

neross

Membre Actif
Inscrit
20 Decembre 2014
Messages
150
Reactions
0
#6
Sinon ne fait pas de boucle infinie. Rappel ton Thread en externe. :)
Tu mets un évent de finissions dans ton thread et une fois finie tu le rappel.
 
Inscrit
10 Mai 2015
Messages
357
Reactions
55
#7
Je dois l'appeler à chaque changement de map, donc non je peux pas.
 
Inscrit
10 Mai 2015
Messages
357
Reactions
55
#8
ReEdit : j'ai trouvé la fonction qui fait augmenter la mémoire :

 
Haut Bas