<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>My Workday</title>
	<atom:link href="http://www.goworkday.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.goworkday.com</link>
	<description>Let&#039;s talk TECH</description>
	<lastBuildDate>Thu, 02 Feb 2012 18:52:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to look up available JVM flags</title>
		<link>http://www.goworkday.com/2012/02/02/how-to-look-up-available-jvm-flags/</link>
		<comments>http://www.goworkday.com/2012/02/02/how-to-look-up-available-jvm-flags/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 18:52:32 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=321</guid>
		<description><![CDATA[<br/>java -XX:+PrintFlagsFinal -version&#124; grep -i Pre intx AllocatePrefetchDistance = 192 {product} intx AllocatePrefetchInstr = 0 {product} intx AllocatePrefetchLines = 4 {product} intx AllocatePrefetchStepSize = 64 {product} intx AllocatePrefetchStyle = 1 {product} bool AlwaysPreTouch = false {product} uintx CMSAbortablePrecleanMinWorkPerIteration = 100 {product} intx CMSAbortablePrecleanWaitMillis = 100 {manageable} uintx CMSMaxAbortablePrecleanLoops = 0 {product} intx CMSMaxAbortablePrecleanTime = 5000 [...]]]></description>
			<content:encoded><![CDATA[<br/><pre></pre>
<pre>java -XX:+PrintFlagsFinal -version| grep -i Pre
     intx AllocatePrefetchDistance                  = 192             {product}
     intx AllocatePrefetchInstr                     = 0               {product}
     intx AllocatePrefetchLines                     = 4               {product}
     intx AllocatePrefetchStepSize                  = 64              {product}
     intx AllocatePrefetchStyle                     = 1               {product}
     bool AlwaysPreTouch                            = false           {product}
    uintx CMSAbortablePrecleanMinWorkPerIteration   = 100             {product}
     intx CMSAbortablePrecleanWaitMillis            = 100             {manageable}
    uintx CMSMaxAbortablePrecleanLoops              = 0               {product}
     intx CMSMaxAbortablePrecleanTime               = 5000            {product}
     bool CMSPermGenPrecleaningEnabled              = true            {product}
    uintx CMSPrecleanDenominator                    = 3               {product}
    uintx CMSPrecleanIter                           = 3               {product}
    uintx CMSPrecleanNumerator                      = 2               {product}
     bool CMSPrecleanRefLists1                      = true            {product}
     bool CMSPrecleanRefLists2                      = false           {product}
     bool CMSPrecleanSurvivors1                     = false           {product}
     bool CMSPrecleanSurvivors2                     = true            {product}
    uintx CMSPrecleanThreshold                      = 1000            {product}
     bool CMSPrecleaningEnabled                     = true            {product}
     bool CompilerThreadHintNoPreempt               = true            {product}
    uintx G1HeapRegionSize                          = 0               {product}
     intx InterpreterProfilePercentage              = 33              {product}
     intx PreBlockSpin                              = 10              {product}
     intx PreInflateSpin                            = 10              {pd product}</pre>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2012/02/02/how-to-look-up-available-jvm-flags/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL: Number of Databases</title>
		<link>http://www.goworkday.com/2011/06/30/mysql-number-of-databases/</link>
		<comments>http://www.goworkday.com/2011/06/30/mysql-number-of-databases/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 21:49:18 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=316</guid>
		<description><![CDATA[<br/>The query to find the total number of databases can be found by executing the following query: select count(*) from information_schema.SCHEMATA where schema_name not in ('mysql','information_schema'); &#160;]]></description>
			<content:encoded><![CDATA[<br/><p>The query to find the total number of databases can be found by executing the following query:</p>
<p><code><br />
select count(*) from information_schema.SCHEMATA where schema_name not in<br />
('mysql','information_schema');</code></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2011/06/30/mysql-number-of-databases/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL &#8211; Poor Man&#8217;s Profiler</title>
		<link>http://www.goworkday.com/2011/05/26/mysql-poor-mans-profiler/</link>
		<comments>http://www.goworkday.com/2011/05/26/mysql-poor-mans-profiler/#comments</comments>
		<pubDate>Fri, 27 May 2011 04:50:43 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=313</guid>
		<description><![CDATA[<br/>Rationale Sampling tools like oprofile or dtrace&#8217;s profile provider don&#8217;t really provide methods to see what [multithreaded] programs are blocking on &#8211; only where they spend CPU time. Though there exist advanced techniques (such as systemtap and dtrace call level probes), it is overkill to build upon that. Poor man doesn&#8217;t have time. Poor man [...]]]></description>
			<content:encoded><![CDATA[<br/><h1><span style="font-size: 20px;">Rationale</span></h1>
<p>Sampling tools like oprofile or dtrace&#8217;s profile provider don&#8217;t really provide methods to see what [multithreaded] programs are blocking on &#8211; only where they spend CPU time. Though there exist advanced techniques (such as systemtap and dtrace call level probes), it is overkill to build upon that. Poor man doesn&#8217;t have time. Poor man needs food.</p>
<h2>Method</h2>
<p>For a poor developer to understand what a program is doing, he needs to see stacks. Once upon a time (back in Linux 2.4) there was a &#8216;pstack&#8217; tool for that, Solaris has it too.</p>
<p>Modern Linux systems though do not have such facilities, and one needs to improvise, like.. use debuggers &#8211; they can walk threads and provide stacks.</p>
<h2>Technology</h2>
<p>Getting stacks:</p>
<pre>gdb -ex "set pagination 0" -ex "thread apply all bt" \
  --batch -p $(pidof mysqld)</pre>
<p>Or for version-impaired (gdb 6.3 and older):</p>
<pre>(echo "set pagination 0";
 echo "thread apply all bt";
 echo "quit"; cat /dev/zero ) | gdb -p $(pidof mysqld)</pre>
<p>Collapsing traces (awk!):</p>
<pre>BEGIN { s = ""; }
/Thread/ { print s; s = ""; }
/^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
END { print s }</pre>
<p>Full technology demonstration:</p>
<pre>#!/bin/bash
nsamples=1
sleeptime=0
pid=$(pidof mysqld)

for x in $(seq 1 $nsamples)
  do
    gdb -ex "set pagination 0" -ex "thread apply all bt" -batch -p $pid
    sleep $sleeptime
  done | \
awk '
  BEGIN { s = ""; }
  /Thread/ { print s; s = ""; }
  /^\#/ { if (s != "" ) { s = s "," $4} else { s = $4 } }
  END { print s }' | \
sort | uniq -c | sort -r -n -k 1,1</pre>
<p>&nbsp;</p>
<h2>Output</h2>
<pre>291 pthread_cond_wait@@GLIBC_2.3.2,one_thread_per_connection_end,handle_one_connection
 57 read,my_real_read,my_net_read,do_command,handle_one_connection,start_thread
 26 pthread_cond_wait@@GLIBC_2.3.2,os_event_wait_low,os_aio_simulated_handle,fil_aio_wait,io_handler_thread,start_thread
  3 pthread_cond_wait@@GLIBC_2.3.2,os_event_wait_low,srv_purge_worker_thread
  1 select,os_thread_sleep,srv_purge_thread
  1 select,os_thread_sleep,srv_master_thread
  1 select,os_thread_sleep,srv_lock_timeout_and_monitor_thread
  1 select,os_thread_sleep,srv_error_monitor_thread
  1 select,handle_connections_sockets,main,select
  1 read,vio_read_buff,my_real_read,my_net_read,cli_safe_read,handle_slave_io
  1 pthread_cond_wait@@GLIBC_2.3.2,os_event_wait_low,sync_array_wait_event,rw_lock_s_lock_spin,buf_page_get_gen,btr_cur_search_to_nth_level,row_search_for_mysql,ha_innodb::index_read,handler::index_read_idx_map,join_read_const,join_read_const_table,make_join_statistics,JOIN::optimize,mysql_select,handle_select,execute_sqlcom_select,mysql_execute_command,mysql_parse,dispatch_command,do_command,handle_one_connection
  1 pread64,os_file_pread,os_file_read,fil_io,buf_read_page_low,buf_read_page,buf_page_get_gen,btr_cur_search_to_nth_level,row_search_index_entry,row_upd_step,row_update_for_mysql,ha_innodb::delete_row,handler::ha_delete_row,mysql_delete,mysql_execute_command,mysql_parse,Query_log_event::do_apply_event,apply_event_and_update_pos,handle_slave_sql
  1 pread64,os_file_pread,os_file_read,fil_io,buf_read_page_low,buf_read_page,buf_page_get_gen,btr_cur_search_to_nth_level,row_search_for_mysql,ha_innodb::index_read,handler::index_read_idx_map,join_read_const,join_read_const_table,make_join_statistics,JOIN::optimize,mysql_select,handle_select,execute_sqlcom_select,mysql_execute_command,mysql_parse,dispatch_command,do_command,handle_one_connection
  1 do_sigwait,sigwait,signal_hand</pre>
<h2>Success stories and references</h2>
<p>We hear this technology has been used by performance engineers at Google, Facebook, Wikipedia, Intel, Sun Microsystems and other places.</p>
<ul>
<li><a href="http://www.xaprb.com/blog/2009/08/30/a-script-snippet-for-aggregating-gdb-backtraces/">Baron Schwartz</a></li>
<li><a href="http://mikaelronstrom.blogspot.com/2009/11/gdb-stack-trace-analysis-of-sysbench.html">Mikael Ronstrom</a></li>
<li><a href="http://bugs.mysql.com/bug.php?id=49463">Mark Callaghan</a></li>
</ul>
<p>&nbsp;</p>
<h2>Credits</h2>
<div>
<div><a href="http://www.facebook.com/pages/PoorMansProfiler/337907684404">PoorMansProfiler</a> on Facebook</div>
</div>
<p>Originally this technology was released as a collaborative effort by Mark Callaghan and Domas Mituzas at <a href="http://mituzas.lt/2009/02/15/poor-mans-contention-profiling/">this blog post</a>.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2011/05/26/mysql-poor-mans-profiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extract RPM package without installing it</title>
		<link>http://www.goworkday.com/2011/05/12/extract-rpm-package-without-installing-it/</link>
		<comments>http://www.goworkday.com/2011/05/12/extract-rpm-package-without-installing-it/#comments</comments>
		<pubDate>Thu, 12 May 2011 18:23:29 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=310</guid>
		<description><![CDATA[<br/>Extract RPM file using rpm2cpio and cpio command: $ rpm2cpio any_rpm_package.x86_64.rpm &#124; cpio -idmv]]></description>
			<content:encoded><![CDATA[<br/><p>Extract RPM file using rpm2cpio and cpio command:<br />
<code><br />
$ rpm2cpio any_rpm_package.x86_64.rpm | cpio -idmv<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2011/05/12/extract-rpm-package-without-installing-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Check Ram Speed and Type</title>
		<link>http://www.goworkday.com/2011/02/17/check-ram-speed-and-type/</link>
		<comments>http://www.goworkday.com/2011/02/17/check-ram-speed-and-type/#comments</comments>
		<pubDate>Thu, 17 Feb 2011 17:26:45 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=307</guid>
		<description><![CDATA[<br/>How do I check RAM speed and type (line DDR or DDR2) without opening my computer? I need to purchase RAM and I need to know the exact speed and type installed. How do I find out ram information from a shell prompt? $ sudo dmidecode --type 17 dmidecode is a tool for dumping a [...]]]></description>
			<content:encoded><![CDATA[<br/><p>How do I check RAM speed and type (line DDR or DDR2) without opening my computer? I need to purchase RAM and I need to know the exact speed and type installed. How do I find out ram information from a shell prompt?<br />
<code><br />
$ sudo dmidecode --type 17<br />
</code></p>
<p> <strong>dmidecode</strong> is a tool for dumping a computer’s DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to  probe  for  the  actual hardware.  While this is a good point in terms of report speed and safeness, this also makes the presented information possibly unreliable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2011/02/17/check-ram-speed-and-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Limiting Pause Time with G1 Collector</title>
		<link>http://www.goworkday.com/2010/10/18/limiting-pause-time-with-g1-collector/</link>
		<comments>http://www.goworkday.com/2010/10/18/limiting-pause-time-with-g1-collector/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 03:06:52 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[G1]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=302</guid>
		<description><![CDATA[<br/>G1 collector is concurrent and parallel with more predictability and better useability. It splits the heap into regions and young and old generational spaces are organized in sets of regions. This eliminates the need to fine tune &#8220;NewSize/MaxNewSize&#8221;. G1 also provides incremental compaction in those regions by &#8220;evacuating&#8221; the regions that are full and fragmented. [...]]]></description>
			<content:encoded><![CDATA[<br/><p>G1 collector is concurrent and parallel with more predictability and better useability. It splits the heap into regions and young and old generational spaces are organized in sets of regions. This eliminates the need to fine tune &#8220;NewSize/MaxNewSize&#8221;. G1 also provides incremental compaction in those regions by &#8220;evacuating&#8221; the regions that are full and fragmented. To try this G1 collector, you&#8217;ll need the aforementioned Fix Pack/Update and the following JVM options:</p>
<p><strong>-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC</strong></p>
<p>In addition, the following options can be used to adjust G1&#8242;s characteristics:</p>
<p>To set the max GC pause time goal in milliseconds that G1 will attempt to meet:</p>
<p><strong>-XX:MaxGCPauseMillis<X></strong></p>
<p>To set the time interval over which GC pauses totaling up to MaxGCPauseMillis may take place:</p>
<p><strong>-XX:GCPauseIntervalMillis<X></strong></p>
<p>For more information about G1 (how it operates, more options, etc.) see Java HotSpot Garbage Collection.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/10/18/limiting-pause-time-with-g1-collector/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title></title>
		<link>http://www.goworkday.com/2010/10/05/java-process-debugging/</link>
		<comments>http://www.goworkday.com/2010/10/05/java-process-debugging/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 07:26:04 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=292</guid>
		<description><![CDATA[<br/>﻿ Hung, Deadlocked, or Looping Process Print thread stack for all Java threads: Control-\ kill -QUIT pid jstack pid (or jstack -F pid if jstack pid does not respond) Detect deadlocks: Request deadlock detection: JConsole tool, Threads tab Print information on deadlocked threads: Control-\ Print list of concurrent locks owned by each thread: -XX:+PrintConcurrentLocks set, then Control-\ Print lock [...]]]></description>
			<content:encoded><![CDATA[<br/><p>﻿<br />
<h3>Hung, Deadlocked, or Looping Process</h3>
<p></br></p>
<ul>
<li>Print thread stack for all Java threads:
<ul>
<li>Control-\</li>
<li>kill -QUIT <em>pid</em></li>
<li>jstack <em>pid</em> (or jstack -F <em>pid</em> if jstack <em>pid</em> does not respond)</li>
</ul>
</li>
<li>Detect deadlocks:
<ul>
<li>Request deadlock detection: JConsole tool, Threads tab</li>
<li>Print information on deadlocked threads: Control-\</li>
<li>Print list of concurrent locks owned by each thread: -XX:+PrintConcurrentLocks set, then Control-\</li>
<li>Print lock information for a process: jstack -l <em>pid</em></li>
</ul>
</li>
<li>Get a heap histogram for a process:
<ul>
<li>Start Java process with -XX:+PrintClassHistogram, then Control-\</li>
<li>jmap -histo <em>pid</em> (with -F option if <em>pid</em> does not respond)</li>
</ul>
</li>
<li>Dump Java heap for a process in binary format to file:
<ul>
<li>jmap -dump:format=b,file=<em>filename pid</em> (with -F option if <em>pid</em> does not respond)</li>
</ul>
</li>
<li>Print shared object mappings for a process:
<ul>
<li>jmap <em>pid</em></li>
</ul>
</li>
<li>Print heap summary for a process:
<ul>
<li>Control-\</li>
<li>jmap -heap <em>pid</em></li>
</ul>
</li>
<li>Print finalization information for a process:
<ul>
<li>jmap -finalizerinfo <em>pid</em></li>
</ul>
</li>
<li>Attach the command-line debugger to a process:
<ul>
<li>jdb -connect sun.jvm.hotspot.jdi.SAPIDAttachingConnector:pid=<em>pid</em></li>
</ul>
</li>
</ul>
<h3>Post-mortem Diagnostics, Memory Leaks</h3>
<p></br></p>
<ul>
<li>Examine the fatal error log file. Default file name is hs_err_pid<em>pid</em>.log in the working-directory.</li>
<li>Create a heap dump:
<ul>
<li>Start the application with HPROF enabled: java -agentlib:hprof=file=<em>file</em>,format=b<em>application</em>; then Control-\</li>
<li>Start the application with HPROF enabled: java -agentlib:hprof=heap=dump <em>application</em></li>
<li>JConsole tool, MBeans tab</li>
<li>Start VM with -XX:+HeapDumpOnOutOfMemoryError; if OutOfMemoryError is thrown, VM generates a heap dump.</li>
</ul>
</li>
<li>Browse Java heap dump:
<ul>
<li>jhat <em>heap-dump-file</em></li>
</ul>
</li>
<li>Dump Java heap from core file in binary format to a file:
<ul>
<li>jmap -dump:format=b,file=<em>filename corefile</em></li>
</ul>
</li>
<li>Get a heap histogram for a process:
<ul>
<li>Start Java process with -XX:+PrintClassHistogram, then Control-\</li>
<li>jmap -histo <em>pid</em> (with -F option if <em>pid</em> does not respond)</li>
</ul>
</li>
<li>Get a heap histogram from a core file:
<ul>
<li>jmap -histo <em>corefile</em></li>
</ul>
</li>
<li>Print shared object mappings from a core file:
<ul>
<li>jmap <em>corefile</em></li>
</ul>
</li>
<li>Print heap summary from a core file:
<ul>
<li>jmap -heap <em>corefile</em></li>
</ul>
</li>
<li>Print finalization information from a core file:
<ul>
<li>jmap -finalizerinfo <em>corefile</em></li>
</ul>
</li>
<li>Print Java configuration information from a core file:
<ul>
<li>jinfo <em>corefile</em></li>
</ul>
</li>
<li>Print thread trace from a core file:
<ul>
<li>jstack <em>corefile</em></li>
</ul>
</li>
<li>Print lock information from a core file:
<ul>
<li>jstack -l <em>corefile</em></li>
</ul>
</li>
<li>Attach the command-line debugger to a core file on the same machine:
<ul>
<li>jdb -connect sun.jvm.hotspot.jdi.SACoreAttachingConnector:javaExecutable=<em>path</em>,core=<em>corefile</em></li>
</ul>
</li>
<li>Attach the command-line debugger to a core file on a different machine:
<ul>
<li>On the machine with the core file: jsadebugd <em>path corefile</em><br />
and on the machine with the debugger: jdb -connect sun.jvm.hotspot.jdi.SADebugServerAttachingConnector:debugServerName=<em>machine</em></li>
</ul>
</li>
<li>libumem can be used to debug memory leaks.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/10/05/java-process-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: Insufficient Memory</title>
		<link>http://www.goworkday.com/2010/09/22/java-insufficient-memory/</link>
		<comments>http://www.goworkday.com/2010/09/22/java-insufficient-memory/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 00:24:51 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=288</guid>
		<description><![CDATA[<br/>The Java Virtual Machine (JVM)* has the following types of memory: heap, non-heap, and native. Heap memory is the runtime data area from which memory for all class instances and arrays is allocated. Non-heap memory includes the method area and memory required for the internal processing or optimization of the JVM. It stores per-class structures [...]]]></description>
			<content:encoded><![CDATA[<br/><p>The Java Virtual Machine (JVM)* has the following types of memory: heap, non-heap, and native.</p>
<p>Heap memory is the runtime data area from which memory for all class instances and arrays is allocated. Non-heap memory includes the method area and memory required for the internal processing or optimization of the JVM. It stores per-class structures such as a runtime constant pool, field and method data, and the code for methods and constructors. Native memory is the virtual memory managed by the operating system. When the memory is insufficient for an application to allocate, a java.lang.OutOfMemoryError will be thrown.</p>
<p>Following are the possible error messages for OutOfMemoryErrors in each type of memory:</p>
<p><strong>Heap memory error:</strong> When an application creates a new object but the heap does not have sufficient space and cannot be expanded further, an OutOfMemoryError will be thrown with the following error message:</p>
<p><code>java.lang.OutOfMemoryError: Java heap space</code></p>
<p><strong>Non-heap memory error:</strong> The permanent generation is a non-heap memory area in the HotSpot VM implementation that stores per-class structures as well as interned strings. When the permanent generation is full, the application will fail to load a class or to allocate an interned string, and an OutOfMemoryError will be thrown with the following error message:</p>
<p><code>java.lang.OutOfMemoryError: PermGen space</code></p>
<p><strong>Native memory error:</strong> The Java Native Interface (JNI) code or the native library of an application and the JVM implementation allocate memory from the native heap. An OutOfMemoryError will be thrown when an allocation in the native heap fails. For example, the following error message indicates insufficient swap space, which could be caused by a configuration issue in the operating system or by another process in the system that is consuming much of the memory:</p>
<p>j<code>ava.lang.OutOfMemoryError: request <size> bytes for <reason>.<br />
Out of swap space?</code></p>
<p>An insufficient memory problem could be due either to a problem with the configuration &#8212; the application really needs that much memory &#8212; or to a performance problem in the application that requires you to profile and optimize to reduce the memory use. </p>
<p>You can find more information at http://java.sun.com/developer/technicalArticles/J2SE/monitoring/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/09/22/java-insufficient-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do you find out what’s classes are being stored in PermGen? Trace class loading/unloading</title>
		<link>http://www.goworkday.com/2010/09/20/how-do-you-find-out-what%e2%80%99s-classes-are-being-stored-in-permgen-trace-class-loadingunloading/</link>
		<comments>http://www.goworkday.com/2010/09/20/how-do-you-find-out-what%e2%80%99s-classes-are-being-stored-in-permgen-trace-class-loadingunloading/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 17:24:54 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=282</guid>
		<description><![CDATA[<br/>PermGen holds the metadata about classes that have been loaded/created. This information is garbage collected like the other parts of the heap, however there are rough edges that can prevent this from happening, class loaders in particular. Generally, the amount of PermGen space needed is small in relation to the rest of the heap. How [...]]]></description>
			<content:encoded><![CDATA[<br/><p>PermGen holds the metadata about classes that have been loaded/created. This information is garbage collected like the other parts of the heap, however there are rough edges that can prevent this from happening, class loaders in particular. Generally, the amount of PermGen space needed is small in relation to the rest of the heap.</p>
<p>How do I know what classes are being loaded or unloaded? Use the command line options </p>
<p>-XX:+TraceClassLoading and -XX:+TraceClassUnloading .</p>
<p>If you suspect that that classloader isn&#8217;t the issue, use <strong>-verbose:class</strong> to investigate classes which have been loaded.  This, as it suggests, will be very verbose.</p>
<p><strong>How do you increase PermGen space?</strong></p>
<p>Increase using the -XX:MaxPermSize option.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/09/20/how-do-you-find-out-what%e2%80%99s-classes-are-being-stored-in-permgen-trace-class-loadingunloading/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Single-word Wang/Jenkins Hash in ConcurrentHashMap</title>
		<link>http://www.goworkday.com/2010/03/19/single-word-wangjenkins-hash-concurrenthashmap/</link>
		<comments>http://www.goworkday.com/2010/03/19/single-word-wangjenkins-hash-concurrenthashmap/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 00:23:16 +0000</pubDate>
		<dc:creator>Admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Bitwise Operation]]></category>
		<category><![CDATA[hash]]></category>

		<guid isPermaLink="false">http://www.goworkday.com/?p=244</guid>
		<description><![CDATA[<br/>ConcurrentHashMap is hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. I recently came across this code during testing, and one part really got my attention. To generate the hash, ConcurrentHashMap uses an algorithm based on bitshifting and bitwise operations. ?View Code JAVA1 2 3 4 5 6 7 8 9 [...]]]></description>
			<content:encoded><![CDATA[<br/><p>ConcurrentHashMap is hash table supporting full concurrency of retrievals and adjustable expected concurrency for updates. I recently came across this code during testing, and one part really got my attention. To generate the hash, ConcurrentHashMap uses an algorithm based on bitshifting and bitwise operations.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code6'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2446"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p244code6"><pre class="java" style="font-family:monospace;"><span style="color: #339933;">========================================</span>
Variant of single<span style="color: #339933;">-</span>word Wang<span style="color: #339933;">/</span>Jenkins hash
<span style="color: #339933;">========================================</span>
<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> hash<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> h<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Spread bits to regularize both segment and index locations,</span>
<span style="color: #666666; font-style: italic;">// using variant of single-word Wang/Jenkins hash.</span>
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span>  <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">^</span> 0xffffcd7d<span style="color: #339933;">;</span>
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span>   <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span>  <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span>   <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">14</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">return</span> h <span style="color: #339933;">^</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>According to the comment in the code, this method applies a supplemental hash function to a given hashCode, which defends against poor quality hash functions.  </p>
<p>Good hash functions are important as a hash table effectively turns from a map to a linked list, in the worst case, all keys in the same bucket. There are also other considerations that come into play such as the performance of hash calculation and the number of buckets. Dr. Heinz M. Kabutz explains the power of <a href="http://www.javaspecialists.co.za/archive/Issue054.html">&#8220;power-of-two number of buckets&#8221;</a> which gives us some good starting point to understand what is really going on here. </p>
<p>Let&#8217;s look at the code above and see how things change, line-by-line. To make things simple,  I use <strong>int 1</strong> to perform all the operations. </p>
<p>In Java, the <strong> int</strong> data type is a 32-bit signed two&#8217;s complement integer. To represent int 1 in binary code, we have the following:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code7'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2447"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p244code7"><pre class="java" style="font-family:monospace;">h<span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&gt;</span> 0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0001</pre></td></tr></table></div>

<p>Now, let&#8217;s dissect the following line:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code8'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2448"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p244code8"><pre class="java" style="font-family:monospace;">h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">^</span> 0xffffcd7d</pre></td></tr></table></div>

<p>First, let&#8217;s re-write this into an easier-to-read format.. at least for me <img src='http://www.goworkday.com/wp-includes/images/smilies/icon_smile.gif' alt="icon smile  Single word Wang/Jenkins Hash in ConcurrentHashMap" class='wp-smiley' title=" Single word Wang/Jenkins Hash in ConcurrentHashMap" /> .</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code9'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p2449"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p244code9"><pre class="java" style="font-family:monospace;">h1 <span style="color: #339933;">=</span> h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">15</span>      <span style="color: #339933;">=</span>  0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span><span style="color: #cc66cc;">1000</span><span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span>0000
hex <span style="color: #339933;">=</span> 0xffffcd7d  <span style="color: #339933;">=</span>  <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1100</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0111<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span>
h2 <span style="color: #339933;">=</span> h1 <span style="color: #339933;">^</span> hex     <span style="color: #339933;">=</span>  <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0111<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span>
h2 <span style="color: #339933;">+</span> h            <span style="color: #339933;">=</span>  <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0111<span style="color: #339933;">-</span><span style="color: #cc66cc;">1110</span></pre></td></tr></table></div>

<p>Using the same thought processing and applying it to each line, we end-up with:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p244code10'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24410"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p244code10"><pre class="java" style="font-family:monospace;">h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">^</span> 0xffffcd7d <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0111<span style="color: #339933;">-</span><span style="color: #cc66cc;">1110</span>
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span>	            <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1100</span><span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span><span style="color: #cc66cc;">1011</span><span style="color: #339933;">-</span>0010<span style="color: #339933;">-</span><span style="color: #cc66cc;">1010</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span>
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span>		    <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1100</span><span style="color: #339933;">-</span>0110<span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1000</span><span style="color: #339933;">-</span>0001<span style="color: #339933;">-</span>0101
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span>              <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1111</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1110</span><span style="color: #339933;">-</span>0011<span style="color: #339933;">-</span>0001<span style="color: #339933;">-</span>0101<span style="color: #339933;">-</span>0001<span style="color: #339933;">-</span>0011<span style="color: #339933;">-</span>0101
h <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&lt;&lt;</span> <span style="color: #cc66cc;">14</span><span style="color: #009900;">&#41;</span>   <span style="color: #339933;">=</span> 0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1011</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span>0011<span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0110<span style="color: #339933;">-</span>0000<span style="color: #339933;">-</span><span style="color: #cc66cc;">1001</span>
h <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span>             <span style="color: #339933;">=</span> 0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1011</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span>0011<span style="color: #339933;">-</span><span style="color: #cc66cc;">1001</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1101</span><span style="color: #339933;">-</span>0100<span style="color: #339933;">-</span><span style="color: #cc66cc;">1010</span></pre></td></tr></table></div>

<p>Result:<br />
Bin          = 0100-1011-0100-0011-1001-1101-0100-1010<br />
Decimal = 1,262,722,378</p>
]]></content:encoded>
			<wfw:commentRss>http://www.goworkday.com/2010/03/19/single-word-wangjenkins-hash-concurrenthashmap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

