Liberar memoria ao fechar Formulario com objeto criado
Moderador: Moderadores
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
No último teste alterei 1002 pra 1001.
De repente, máxima memória usada poderia ser o máximo que atingiu, e não o uso atual.
O resultado foi parecido.
De repente, máxima memória usada poderia ser o máximo que atingiu, e não o uso atual.
O resultado foi parecido.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- Itamar M. Lins Jr.
- Administrador

- Mensagens: 7928
- Registrado em: 30 Mai 2007 11:31
- Localização: Ilheus Bahia
- Curtiu: 1 vez
Liberar memoria ao fechar Formulario com objeto criado
Olá!
No Linux dá tudo zero.
Depois eu testo no ruindows.
Mudei aqui para vários ou dá 9999 ou 0
Não entendi nada.
Saudações,
Itamar M. Lins Jr.
No Linux dá tudo zero.
Depois eu testo no ruindows.
Mudei aqui para vários ou dá 9999 ou 0
Não entendi nada.
Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Itamar M. Lins Jr.
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
teste 3 vezes seguidas
o resultado não é sempre o mesmo.
Código: Selecionar todos
#define MEM_TEST 1001
PROCEDURE Main
LOCAL F, aLista := {}, nCont
SetMode(40,100)
CLS
FOR nCont = 1 TO 3
? "Antes do array: " + Ltrim( Str( Memory(MEM_TEST) ) )
FOR F := 1 TO 1000000
AAdd( aLista, { F, Hb_RandomInt(99) , hb_RandomInt(99), Date() - F, F % 2 == 0, hb_RandomInt(99), F * 10 } )
NEXT
? "Depois do array: " + Ltrim( Str( Memory(MEM_TEST) ) )
aLista := {}
( aLista )
? "Zerando: " + Ltrim( Str( Memory(MEM_TEST) ) )
hb_GcAll()
? "hb_gcAll() : " + Ltrim( Str( Memory(MEM_TEST) ) )
NEXT
Inkey(0)
RETURN
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
E por último, em CONSOLE, sem GTWVG.
Antes do array: 262144
Depois do array: 261423104
Zerando: 231800832
hb_gcAll() : 230817792
Antes do array: 230817792
Depois do array: 261423104
Zerando: 589824
hb_gcAll() : 589824
Antes do array: 589824
Depois do array: 261423104
Zerando: 230817792
hb_gcAll() : 230817792
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
Mais um teste, atribuindo NIL melhorou muuuuuuuuito, mas continua um resto:
Código: Selecionar todos
#define MEM_TEST 1001
PROCEDURE Main
LOCAL F, aLista := {}, nCont
SetMode(40,100)
CLS
FOR nCont = 1 TO 3
? "Antes do array: " + Ltrim( Str( Memory(MEM_TEST) ) )
FOR F := 1 TO 1000000
AAdd( aLista, { F, Hb_RandomInt(99) , hb_RandomInt(99), Date() - F, F % 2 == 0, hb_RandomInt(99), F * 10 } )
NEXT
? "Depois do array: " + Ltrim( Str( Memory(MEM_TEST) ) )
aLista := Nil
aLista := {}
Inkey(1)
( aLista )
? "Zerando: " + Ltrim( Str( Memory(MEM_TEST) ) )
hb_GcAll()
Inkey(1)
? "hb_gcAll() : " + Ltrim( Str( Memory(MEM_TEST) ) )
NEXT
Inkey(0)
RETURN
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
Isso acima já foi ruim..... mas pode piorar....
Agora é que fud. tudo.
Código: Selecionar todos
#include "hbmemory.ch"
#define MEM_TEST HB_MEM_USED
#pragma -w0
PROCEDURE Main
LOCAL nCont
SetMode(40,100)
CLS
FOR nCont = 1 TO 3
SubTest()
NEXT
Inkey(0)
RETURN
FUNCTION SubTest()
LOCAL aList, F
aList := {}
? "Before array: " + Ltrim( Str( Memory(MEM_TEST) ) )
FOR F := 1 TO 1000000
AAdd( aList, { F, Hb_RandomInt(99) , hb_RandomInt(99), Date() - F, F % 2 == 0, hb_RandomInt(99), F * 10 } )
NEXT
? "After array: " + Ltrim( Str( Memory(MEM_TEST) ) )
aList := {}
? "Empty List: " + Ltrim( Str( Memory(MEM_TEST) ) )
aList := Nil
? "Nil: " + Ltrim( Str( MEM_TEST ) )
RETURN Nil
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
Porque se contentar só com isso, vamos fud. mais ainda.
Que tal um resultado diferente a cada execução ?
Que tal um resultado diferente a cada execução ?
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- Itamar M. Lins Jr.
- Administrador

- Mensagens: 7928
- Registrado em: 30 Mai 2007 11:31
- Localização: Ilheus Bahia
- Curtiu: 1 vez
Liberar memoria ao fechar Formulario com objeto criado
Olá!
Essa memória ai deve ser do OS. O windows que cuida disso.
Quando tem um release, é no nosso sistema, depois a hora quando achar que deve o windows executa, um buffer sei lá...
Seria bom ver o painel do windows de memória alocada.
Saudações,
Itamar M. Lins Jr.
Essa memória ai deve ser do OS. O windows que cuida disso.
Quando tem um release, é no nosso sistema, depois a hora quando achar que deve o windows executa, um buffer sei lá...
Seria bom ver o painel do windows de memória alocada.
Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Itamar M. Lins Jr.
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
Pior ainda....
Como pode após zerar, reduzir o uso de memória, ele aparecer maior ?
Notaram isso?
Não entendi mais nada.
Como pode após zerar, reduzir o uso de memória, ele aparecer maior ?
Notaram isso?
Não entendi mais nada.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
Não fez nenhum sentido, porque ao atribuir NIL reduziu, mas no próximo teste, voltou com memória alocada, a que tinha sumido.Itamar M. Lins Jr. escreveu:Essa memória ai deve ser do OS. O windows que cuida disso.
Quando tem um release, é no nosso sistema, depois a hora quando achar que deve o windows executa, um buffer sei lá...
Seria bom ver o painel do windows de memória alocada.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
É como se a variável LOCAL tivesse virado STATIC, ou algo assim.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- Itamar M. Lins Jr.
- Administrador

- Mensagens: 7928
- Registrado em: 30 Mai 2007 11:31
- Localização: Ilheus Bahia
- Curtiu: 1 vez
Liberar memoria ao fechar Formulario com objeto criado
Olá!
Tem uns testes na pasta /tests
Tem memory.prg também.
Saudações,
Itamar M. Lins Jr.
Tem uns testes na pasta /tests
Código: Selecionar todos
itamar@itamar-desktop:~/dev/hb32/tests$ cat mem.prg
// Testing memory release
PROCEDURE Main()
LOCAL a, b
a := "Hello"
b := 2
HB_SYMBOL_UNUSED( a )
HB_SYMBOL_UNUSED( b )
RETURN
Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Itamar M. Lins Jr.
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
Cometi um erro no fonte, mas acabei postando no harbour-users com o erro.
Após NIL, ao invés de Memory(MEM_TEST) coloquei MEM_TEST apenas, por isso o 1001.
Pelo menos tanto faz Nil ou não, mas a diferença continua.
Após NIL, ao invés de Memory(MEM_TEST) coloquei MEM_TEST apenas, por isso o 1001.
Pelo menos tanto faz Nil ou não, mas a diferença continua.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
fonte corrigido
Nota: O copiar/colar do console no windows 10 tá uma bost... vira um linguição.
Código: Selecionar todos
#include "hbmemory.ch"
#define MEM_TEST HB_MEM_USED
#pragma -w0
PROCEDURE Main
LOCAL nCont
SetMode(40,100)
CLS
? "Main: " + Ltrim( Str( Memory(MEM_TEST) ) )
FOR nCont = 1 TO 3
?
? "Main before subtest: " + Ltrim( Str( Memory(MEM_TEST) ) )
SubTest()
? "Main after subtest: " + Ltrim( Str( Memory(MEM_TEST) ) )
NEXT
?
? "Main after for/next: " + Ltrim( Str( Memory(MEM_TEST) ) )
Inkey(0)
RETURN
FUNCTION SubTest()
LOCAL aList, F
aList := {}
? "Before array: " + Ltrim( Str( Memory(MEM_TEST) ) )
FOR F := 1 TO 1000000
AAdd( aList, { F, Hb_RandomInt(99) , hb_RandomInt(99), Date() - F, F % 2 == 0, hb_RandomInt(99), F * 10 } )
NEXT
? "After array: " + Ltrim( Str( Memory(MEM_TEST) ) )
aList := {}
? "Empty List: " + Ltrim( Str( Memory(MEM_TEST) ) )
aList := Nil
? "Nil: " + Ltrim( Str( Memory(MEM_TEST )) )
RETURN Nil
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
Liberar memoria ao fechar Formulario com objeto criado
Sei lá se serve pra alguma coisa, é o programa de teste com as várias opções de memory.
Código: Selecionar todos
HB_MEM_CHAR 2097151
HB_MEM_BLOCK 2097151
HB_MEM_RUN 2097151
HB_MEM_VM 2032088
HB_MEM_EMS 0
HB_MEM_FM 2097151
HB_MEM_FMSEGS 1
HB_MEM_SWAP 4194303
HB_MEM_CONV 0
HB_MEM_EMSUSED 0
HB_MEM_USED 13172736
HB_MEM_USEDMAX 13172736
HB_MEM_STACKITEMS 200
HB_MEM_STACK 4800
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/