🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.lenguajes.java
Article #28157

Re: A vueltas con el System.gc()

#28157
From: Juan Gonzalo de Silva Medina
Date: Mon, 25 May 1998 00:00
132 lines
6257 bytes
Este es un mensaje multipartes en formato MIME.
--------------0FFB9BE17939DF07554D844C
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit



Jos� Manuel L�pez Cobo escribi�:

> Gracias a los compa�eros que me ayudaron con mi anterior duda.
>     Pero, el problema no se ha solucionado por completo. Me he percatado que
> mi programa consume muchos recursos gr�ficos, as� que he instalado
> finalizadores en todas las clases que manejan gr�ficos. En un determinado
> momento, llamo al System.runFinalization() y al System.gc(). El problema
> surge cuando Windows95, se pasa la limpieza de la basura por el forro de los
> chips, y no recolecta ni una �nfima parte de la memoria "deallocated".
>     La cosa sigue: He probado el mismo programa en Windows NT 4.0 y !!oh,
> sorpresa��, el programa consume recursos (desde luego), pero no a la
> velocidad fagocitadora con la que lo hace en W95.
>
>     Y la pregunta es:
>         Alguien sabe como despertar al recolector de basura de W95 ?
>         O, existe alguna manera de economizar recursos, para que esto no
> ocurra.
>
>     Nota para Juan Gonzalo: Te agradezco enormemente tu esfuerzo, pero me ha
> sonado a chino (la respuesta ha tardado mucho en llegarme, porque he tenido
> el PC jodido). Podr�as volver a mandarme la respuesta un poquito m�s claro ?
> (es decir, JAVA para megatorpes). �C�mo puedo ampliar esos par�metros de los
> que hablas, y lo que es m�s importante, desde d�nde son accesibles ?. Te
> agradezco de antemano tu esfuerzo y comprensi�n.


:-) sin importar...

Al llamar al JRE.EXE o al JAVA.EXE, puedes ver una serie de par�metros que
tienes disponible en cuanto a la memoria, te los copio directamente de sun:

-mxx
     Sets the maximum size of the memory allocation pool (the garbage collected
heap) to x. The default is 16 megabytes of memory. x must be greater than or
equal to 1000 bytes.

     By default, x is measured in bytes. You can specify x in either kilobytes
or megabytes by appending the letter "k" for kilobytes or the letter "m" for
megabytes.

-ms x
     Sets the startup size of the memory allocation pool (the garbage collected
heap) to x. The default is 1 megabyte of memory. x must be > 1000   bytes.

By default, x is measured in bytes. You can specify x in either kilobytes or
megabytes by appending the letter "k" for kilobytes or the letter "m" for
megabytes.

-ssx
     Each Java thread has two stacks: one for Java code and one for C code. The
-ss option sets the maximum stack size that can be used by C code in a thread to
x. Every thread that is spawned during the execution of the program passed to
jre has x as its C stack size. The default units for x are bytes. The value of x
must be greater than or equal to 1000 bytes.

You can modify the meaning of x by appending either the letter "k" for kilobytes
or the letter "m" for megabytes. The default stack size is 128  kilobytes
("-ss128k").

-ossx
     Each Java thread has two stacks: one for Java code and one for C code. The
-oss option sets the maximum stack size that can be used by Java code in a
thread to x. Every thread that is spawned during the execution of the program
passed to jre has x as its Java stack size. The default units for x are bytes.
The value of x must be greater than or equal to 1000 bytes.

You can modify the meaning of x by appending either the letter "k" for kilobytes
or the letter "m" for megabytes. The default stack size is 400 kilobytes
("-oss400k").

Como puedes ver con estos par�metros se controla totalmente el sistema y la
cantidad de asignaci�n de memoria.

Prueba a modificar algunos de ellos para evitar el error de fin de memoria. Ya
que seguramente tengas m�s memoria de la que el java est� utilizando.

El documento est� en:

http://java.sun.com/products/jdk/1.1/docs/tooldocs/win32/jre.html

Con respecto a los recursos consumidos, tienes que tener en cuenta que llamar al
GC no te garantiza que entre, de echo, seg�n la documentaci�n, la llamada al GC
lo que se realice una marca para indicar que el GC tiene que entrar cuando el
sistema est� lo suficientemente liberado... As� que si lo tienes castigado
continuamente dificilmente te limpiar�.

Lo que no conozco muy bien son los mecanismos de recuperaci�n de memoria que
tiene ambos sistemas. As�, si en Win95 el GC libera 3Mb de memoria, puede ser
que el no lo libere realmente sino que lo marque como libre para reutilizar, en
cambio en NT, el mecanismo puede realizar una liberaci�n efectiva. Todo depende
del API utilizada y de su implementaci�n en dichos S.O.

Si no te importa comentame que quieres decir por consumir muchos recursos CPU,
GUI, Memoria...

Espero que te sirva...




--------------0FFB9BE17939DF07554D844C
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Tarjeta de Juan Gonzalo de Silva Medina
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Juan Gonzalo de Silva Medina
n:              de Silva Medina;Juan Gonzalo
org:            EL MONTE - Dpto. Desarrollo Inform�tico
adr:            AV. Doctor Fedriani n� 23 p1 2C;;;Sevilla;Sevilla;41009;Espa�a
email;internet: gonzalo@caymasa.es
title:          Analista Programador
tel;work:       34-95-4591436
tel;fax:        34-95-4591448
tel;home:       34-95-4906327
note:           ICQ-12816591
x-mozilla-cpt:  ;0
x-mozilla-html: TRUE
version:        2.1
end:            vcard


--------------0FFB9BE17939DF07554D844C--
Technical Details
Message-ID: <3569C3D6.E1AA4D44@caymasa.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <896013086.440664@cache>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: 1116f3,e373d29ef3bd7efd
X-Google-Attributes: gid1116f3,public
From: Juan Gonzalo de Silva Medina <gonzalo@caymasa.es>
Subject: Re: A vueltas con el System.gc()
Date: 1998/05/25
Message-ID: <3569C3D6.E1AA4D44@caymasa.es>
X-Deja-AN: 356590022
References: <896013086.440664@cache>
To: "Jos� Manuel L�pez Cobo" <ozelopez@publynet.com>
Content-Type: multipart/mixed; boundary="------------0FFB9BE17939DF07554D844C"
Organization: EL MONTE
Mime-Version: 1.0
Newsgroups: es.comp.lenguajes.java