BDBits Bytes

Entries from April 2009

Java jvm PermGen errors

April 3, 2009 · Leave a Comment

I recently set up a Tomcat 6.x server for our Documentum web apps, which are java-based. Annoyingly, I was regularly getting error messages saying there was insufficient memory and “PermGen” space. I won’t go into great detail about this, but at a high level, a java virtual machine (jvm) has internal memory allocations that are periodically garbage-collected, i.e. no-longer-needed allocations are cleaned out and the space freed. There is a lot of debate about why and whose code is at fault, but the fact remains it doesn’t seem to work very well right now, particularly for PermGen space. Fortunately, after much gleaning and some experimentation, I found some startup parameters that seem to have resolved it for me. YMMV and all that, of course.

In Tomcat on Windows (yeah I know), go to Start > All Programs > Apache Tomcat 6.0 > Configure Tomcat > Java and put these in the Java Options textbox. For any other platform or java server, you probably already know where these go. :)  MaxPermSize may need tweaking depending on the java apps you are running. If you still get errors that indicate you are running out of PermGen, try increasing MaxPermSize, but there is a limit depending on your total memory allocation. I have mine set to 1024M max memory and Tomcat wouldn’t even start if I set MaxPermSize to large values like 512M. If you need that much PermGen you will need to allocate more total memory as well. MaxPermSize=128M seems to have been enough in my case. You’ll just have to experiment – or find a better blog post.

-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:MaxPermSize=128M

Categories: Uncategorized

Moving a SQL Server 2005 transaction log

April 2, 2009 · Leave a Comment

Since I don’t do this very often, I always have to refresh my memory on the process. It is easily found via your favorite search engine, but since part of my reason for this blog is to consolidate the places I have to go to look for this kind of thing, I’m going to post it here. :)

  1. Document the current database permissions.
  2. Make sure there are no active connections to the database. Really, you need to do this.
  3. Check where the current files are located before you detach the database.
  4. Detach the database. In SQL Server Management Studio (SSMS), just right-click the database and choose Tasks > Detach… and click OK. The database will disappear from SSMS (gasp!).
  5. Move the transaction log file.
  6. Back in SSMS, right click Databases and pick Attach…, click Add, find your .mdb file and click OK.
  7. In the dialog on the bottom part (database details), you will see the log file has Not Found under the Message column. Fix the pathname of the log file to the new location, use the button if you like or just type it in. The error message should disappear.
  8. Click OK. Your database is back.
  9. Check the database permissions and fix them up as needed from the documentation you created earlier.

Categories: SQL Server