15 de septiembre de 2011

¿Cuánta memoria usa cada clase en Java?

Las siguientes herramientas nos ayudarán a diagnosticar en qué se consume la memoria heap en la máquina virtual de Java: jmap y jhat, las cuales están incluidas en el JDK.

Heap histogram

The jmap command will help you get a heap histogram that shows the per-class statistics, including the total number of instances and the total number of bytes occupied by the instances of each class.

http://java.sun.com/developer/technicalArticles/J2SE/monitoring/#Heap_Histogram

$ <JDK>/bin/jmap -histo:live <pid>
num   #instances    #bytes  class name
--------------------------------------
  1:    100000    41600000  [LMemLeak$LeakingClass;
  2:    100000     2400000  MemLeak$LeakingClass
  3:     12726     1337184  <constMethodKlass>
  4:     12726     1021872  <methodKlass>
  5:       694      915336  [Ljava.lang.Object;
  6:     19443      781536  <symbolKlass>
  7:      1177      591128  <constantPoolKlass>
  8:      1177      456152  <instanceKlassKlass>
  9:      1117      393744  <constantPoolCacheKlass>
 10:      1360      246632  [B
 11:      3799      238040  [C
 12:     10042      160672  MemLeak$FinalizableObject
 13:      1321      126816  java.lang.Class
 14:      1740       98832  [S
 15:      4004       96096  java.lang.String
 < more .....>

Heap dump & analysis

http://java.sun.com/developer/technicalArticles/J2SE/monitoring/#Heap_Dump
http://java.sun.com/developer/technicalArticles/J2SE/monitoring/#Heap_Analysis

You can use the jmap command to get a heap dump with this command line:

$ <JDK>/bin/jmap -dump:live,file=heap.dump.out,format=b <pid>

You can use the jhat command to do the heap analysis and determine which references are keeping the leak suspect alive:

$ <JDK>/bin/jhat heap.dump.out

This tool supports a number of queries including the following:
  • Show all reference paths from the root set to a given object. This is particularly useful for finding memory leaks. 
  • Show the instance counts for all classes. 
  • Show the heap histogram including the instance counts and sizes for all classes. 
  • Show the finalizer summary.

21 de julio de 2011

PasteHTML: Web hosting gratuito, sin publicidad y anónimo

Imagen: (c) PasteHTML.com
Necesitaba un servicio de web hosting gratuito que no agregara ningún aviso de publicidad. Mejor dicho, que no modificara la página de ninguna manera, pues necesitaba arreglar una página HTML que contiene CSS y Javascript para que se viera y funcionara mejor en una iPad. Por supuesto, he usado Zymic anteriormente, pero por alguna razón no podía accederlo hoy. Como alternativa, encontré PasteHTML, un curioso servicio en el que simplemente escribes —o pegas— el código HTML, y lo publicas.

16 de julio de 2011

Sombras usando sólo CCS3

Para lograr el efecto de sombra en el siguiente texto, usando únicamente CSS3, usé el siguiente código: