Coder's Revolution

Do you want a revolution?

Pulling Used PermGen Space Programmatically in ColdFusion/Java

If you're lucky, and by lucky I mean smart, you have FusionReactor installed on your server.  The breadth and usefulness of the information afforded by the tool (especially when it comes to memory and garbage collection) is lost on most who use it.  On some occasions you may find yourself needing to pull some memory numbers on an old server (or maybe just someone else's server) who doesn't have any tools installed.  I found myself in this situation the other day when tweaking an old legacy server.  It's sharing 1GB of ram between CFMX7, Railo, Apache, MySQL, and Linux.  It actually operates pretty good on so little memory.  After converting a couple of the legacy sites over to ContentBox which utilizes ORM and in-memory caching for performance I needed to tweak the heap space to be a bit bigger in Railo but I needed to decrease something else to make room. 

Now, this old server doesn't have FusionReactor installed, but it does have SeeFusion and while that tells me the usage of my heap space it doesn't show me the amount of permanent generation that's in use.  Remember, perm gen is stored outside of heap so the total memory footprint  of CF will roughly be heap + permgen.  (Of course, that comes with a few caveats, namely that you're actually using a JVM with a permanent generation!)

I wanted to trim down the perm gen space on CF and Railo to make room for a bigger heap.  I knew what the starting and max perm gen sizes were from my -XX:PermSize and -XX:MaxPermSize JVM args, but I didn't know how much of that was actually being used!  Of course, I could enable verbose GC logging, but that's a lot of work to parse through and I would have to restart the server and wait for the JVM to "warm up" again.  Instead I used a Java class called ManagementFactory.  This class will give you stats on each of your memory spaces in including your new and old generations (part of the heap).  Based on your JVM and your garbage collector in use, you will see different names for the memory spaces, but this bit of code will get you started to see how many MB of space are currently allocated and how much of that allocated space is in use.  Keep in mind that perm gen is not typically garbage collected, so once it goes up you won't see it go down.

<cfscript>
iter = createObject("java","java.lang.management.ManagementFactory").getMemoryPoolMXBeans().iterator();
while (iter.hasNext())
{
    item = iter.next();
    name = item.getName();
    type = item.getType().toString();
    used = item.getUsage().getUsed()/1024/1024;
    max = item.getUsage().getMax()/1024/1024;
    
    writeOutput("#name# (#type#)<br>");
    writeOutput("#round(used)#MB / #round(max)#MB <br><br>");
}
</cfscript>

Here is the output from my local CF10 install.

Code Cache (Non-heap memory)
5MB / 48MB 

PS Eden Space (Heap memory)
82MB / 150MB 

PS Survivor Space (Heap memory)
6MB / 92MB 

PS Old Gen (Heap memory)
363MB / 683MB 

PS Perm Gen (Non-heap memory)
83MB / 512MB

Try dumping out the Java object that comes back from getUsage() and see what other methods you can call.  Hint, getUsage().toString() is a good place to start.

0

CFML, Meet Runnable.com For Live Code Sharing

ColdBox, ColdFusion, GitHub, Railo, Runnable

You may have seen be tweeting about Runnable.com this week.  I've spent a decent amount of time figuring out how their platform works and getting CFML (Railo) running on it.  Basically, Runnable.com is CFLive.net, trycf.com, and JSFiddle.net all mashed up and super cool.  In short, the platform lets developers post any code samples they want for any database/language/framework up on the Internet so other developers can come along and not only read their code, but run it right there in the browser.  It doesn't stop there, other developers and fiddle with the original code and run the new version right there on the site to figure out how it works.  

It's all possible with Docker.io, a cool virtualization platform I just learned about, and Runnable has the whole thing running on top of Amazons EC2.  Basically, each code sample is an entire Linux VM with whatever installed on it that the publisher wanted to set up.  The template of this VM is stored and every time a visitor comes to the site and wants to check out that code sample, a dedicated VM is spun up in seconds just for that user.  Docker.io allows them to simultaneously service hundreds of users because it shares overlapping resources between the VMs so they're very lightweight and come online in seconds.

And since each user gets their own isolated playground, there's no sandbox security to worry about.  In fact, each code page has an emulated bash shell with root privileges at the bottom of the page!  Any local changes made by the visitors of the site, are discarded after they close their browser and the session times out.  The code samples aren't limited to a single file of code-- publishers can create tutorials to demo entire frameworks, with multiple files. Need a database?  Install one.  Need Tomcat? Install it.

So, speaking of Tomcat-- this is where ColdFusion comes in.  Runnable's Twitter account popped into a recent conversation and urged us to get CFML setup, so i took the task and ran with it.  Due to some issue with the Railo installer which they're looking at, I installed Tomcat 7 with apt-get and deployed Railo 4.1 as a WAR file in the root context.  The Runnable guys were super helpful.  They exchanged several E-mails with me and even chatted on Skype for an hour last week answering questions, tweaking my setup, and writing down suggestions.  

I published a proof-of-concept Runnable called CFML Templating With Tags and then a more involved followup called Use WireBox To Create Objects In ColdBox.  I've also created a new GitHub organization called cf-runnable to store all my tutorials.  Feel free to send me pull requests, or ask to collaborate and store your CFML runnables there as well.  Now, what's really, REALLY cool about Runnable is anyone can clone one of my tutorials, make it their own, and re-publish it under their name.  That means no one else has to reinvent the wheel to start putting cool code up on Runnable-- I've already figured a lot of it out and you can springboard off of what I've done, or dive in fresh yourself.

So this is the intro to a blog series I'm going to do how how I got Runnable working with CFML, what little speedbumps I've hit, and how I've been integrating with GitHub to version and host my code.  I have a lot of ideas for Runnable- both improvements for them (like beefier descriptions, and embeddable runnables) and ColdBox-themed tutorials I want to create to let people play around with simple examples and how-to's.  Stay tuned!

3

Coder's Revolution Is Now Running ContentBox CMS

ColdBox, ColdFusion, ContentBox, General

I am proud to have finally brought my blog into the new age my converting from BlogCFC which served me well for many years to ContentBox Modular CMS.  Other than a few case-sensitivity glitches moving my database from a Windows backup to my Linux server, it went very well.  Contentbox has a built-in BlogCFC converter which is very nice and pulled across all my content, categories, comments, users, etc in just a minute or so.  I also wrote a simple open source module for ContentBox which will support the old BlogCFC-style links to entries, pages, and RSS feeds so old links will still work.  I am using Computer Know How's Bootswatch Theme.

 Both the URL compatibility module and the Bootswatch theme are available on ForgeBox and can be installed directly from the ContentBox admin with the click of a button.  This is part of why ContentBox is so advanced and extensible.  Hopefully I'll blog a bit more now that I've got all the new ContentBox features.  I know I still need to do some cleanup on the code formatting in some of my entries.  If you see any broken links for functionality, please let me know so I can take a look and fix it.

3

Topics I Upvoted For cf.Objective() 2014

CFObjective
I've voted for the cf.Objective() topics I'd most like to see this year. I purposefully waited to vote until the board was fully populated since I wanted to give full opportunity to the late comers. It was actually kind of hard to decide since I felt bad NOT voting for everything. I tried to stick to a couple topics from the category. I also did my best to ignore the current number of votes and the presenter just to stay unbiased.

And in case you're wondering, no I didn't vote for my own topics. I figure if it takes my vote to get chosen it probably wasn't that good of a choice :) Here's what I chose and why:
4

My cf.Objective() 2014 Submissions & VOTE!

CFObjective, ColdFusion, Railo
Everyone seemed to be tweeting out their cf.Objective() 2014 submissions today so I figured I would as well. However, not being able to fit much in 140 characters, I figured I would stick it in a quick blog entry. Firstly, I like the open voting format this year. it seemed to work well for CF Summit and I didn't hear a single complaint about the content there. After a slow start, I see a good number of additional topics have flowed into the board this last week or so. I've submitted 3 topics of my own for consideration on the cf.Objective() 2014 Trello board. They are thusly:
2

cf.Objective() Session-- Grow a Backbone.js and drag your apps out of the past with JS Templating

cf.Objective()
Yesterday I talked briefly about my Agile session I'll be presenting at cf.Objective(). Today I'd like to give a quick mention to my Backbone.js session I'll also be giving at 9am Saturday the 18th. I'll admit, I'm a little nervous about this topic simply because it's farther outside my normal comfort zone. The push to improve myself as a developer and learn some front-end JavaScripting frameworks has been a recent and exciting one.
0

cf.Objective() Session-- Waterfall to Agile: Improve your Project Workflow Without Drowning

cf.Objective()
cf.Objective() is almost upon us and I'm super excited as this will be my first year as an attendee and a speaker. I wanted to give a brief teaser for my session, "Waterfall to Agile: Improve your Project Workflow Without Drowning" which is currently scheduled to occur at 1:45 on Saturday the 18th. I am the most excited about this topic and here's some reasons why.
0

ContentBox is Giving Away a Kindle Fire for Christmas

ColdBox, ContentBox, General
ContentBox and Ortus Solutions just announced a new contest today. All you have to do is write an original ContentBox Theme or Module and submit it to ForgeBox by the Dec 14th deadline.

First prize is a Kindle Fire and a $50 Amazon Gift Card. Runner up is $50 worth of iTunes and Amazon Gift Cards. We're excited to see what the community comes up with.
0

My "One Tough Puzzle" JavaScript Brute Force Solution

General, JavaScript, Technology
So, I've been sitting on this for months (because I'm lazy) and decided it's finally time to post it. My mother-in-law visited a while back and brought a puzzle for the kids to play with. It's called "One Tough Puzzle". It claims to have "more the 300,000 wrong ways, but only one right way to assemble it." Well, after fiddling with it for a while, I did what any code-blooded hacker would do and wrote some JavaScript to brute force solve it.
2

What do you want in ColdBox?

CacheBox, ColdBox, ColdFusion, LogBox, WireBox
Team ColdBox is working on putting together a list of features for our 4.0 release. Before we finalize anything, we'd like to hear from you. Please give us your wishlist for the ColdBox Platform and what you'd like to see us work on. There's always items like documentation and additional screen casts, etc but let's focus specifically on what development items we can do to make ColdBox faster, easier, smarter, and flexible for YOU. No suggestion is too big or small. ColdBox Platform
  • Core MVC
  • WireBox
  • LogBox
  • CacheBox
  • MockBox
I started a thread on the official ColdBox mailing list>, but I also want to open up comments for people not in the Google Group. Please leave a comment with your thoughts and suggestions.
0