changeset 2221:5f9796fc1044

Profiled memory usage and implemented proper cleanup for C++ side. 2010-04-06 Deepak Bhole <dbhole@redhat.com> * plugin/icedteanp/IcedTeaJavaRequestProcessor.cc (newMessageOnBus): Update to used string pointer vector (form strSplit) instead of a string vector. Correctly free memory. * plugin/icedteanp/IcedTeaPluginRequestProcessor.cc: Initialize message_queue to be a string pointer vector vector instead of a string vector vector. (newMessageOnBus): Update to used string pointer vector (form strSplit) instead of a string vector. Correctly free memory. (sendWindow): Deal with string pointers instead of strings for message parts. (eval): Same. (call): Same. (sendString): Same. (setMember): Same. (sendMember): Same. (finalize): Same. (queue_processor): Same. Also, free message part memory after processing. * plugin/icedteanp/IcedTeaPluginRequestProcessor.h: Change method signatures to deal with string pointer vectors instead of string vectors. * plugin/icedteanp/IcedTeaPluginUtils.cc (stringToJSID): Added another signature that receives a string pointer. (strSplit): Return string pointer vector instead of string vector. (getUTF8String): Change signature to receive string pointer vector instead of string vector. Update function accordingly. (getUTF16LEString): Same. (subscribe): Make subscription atomic. (unSubscribe): Make unsubscription atomic, bound to same lock as subscribe(). (post): Make list iteration and processing atomic, bound to same lock as subscribe and unSubscribe. * plugin/icedteanp/IcedTeaPluginUtils.h: Added new signature for stringToJSID and updated signatures for strSplit, getUTF8String and getUTF16LEString. * plugin/icedteanp/IcedTeaScriptablePluginObject.cc (IcedTeaScriptableJavaPackageObject::deAllocate): Implemented method. (IcedTeaScriptableJavaPackageObject::invalidate): Same. (IcedTeaScriptableJavaObject::deAllocate): Same. (IcedTeaScriptableJavaObject::invalidate): Same.
author Deepak Bhole <dbhole@redhat.com>
date Tue, 06 Apr 2010 14:17:02 -0400
parents 2e07af30973e
children 1a1eb2d55ea9
files ChangeLog plugin/icedteanp/IcedTeaJavaRequestProcessor.cc plugin/icedteanp/IcedTeaPluginRequestProcessor.cc plugin/icedteanp/IcedTeaPluginRequestProcessor.h plugin/icedteanp/IcedTeaPluginUtils.cc plugin/icedteanp/IcedTeaPluginUtils.h plugin/icedteanp/IcedTeaScriptablePluginObject.cc
diffstat 7 files changed, 211 insertions(+), 151 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jun 04 19:45:32 2010 +0100
+++ b/ChangeLog	Tue Apr 06 14:17:02 2010 -0400
@@ -1,3 +1,44 @@
+2010-04-06  Deepak Bhole <dbhole@redhat.com>
+
+	* plugin/icedteanp/IcedTeaJavaRequestProcessor.cc
+	(newMessageOnBus): Update to used string pointer vector (form strSplit)
+	instead of a string vector. Correctly free memory.
+	* plugin/icedteanp/IcedTeaPluginRequestProcessor.cc: Initialize
+	message_queue to be a string pointer vector vector instead of a string
+	vector vector.
+	(newMessageOnBus): Update to used string pointer vector (form strSplit) 
+	instead of a string vector. Correctly free memory.
+	(sendWindow): Deal with string pointers instead of strings for message
+	parts.
+	(eval): Same.
+	(call): Same.
+	(sendString): Same.
+	(setMember): Same.
+	(sendMember): Same.
+	(finalize): Same.
+	(queue_processor): Same. Also, free message part memory after processing.
+	* plugin/icedteanp/IcedTeaPluginRequestProcessor.h: Change method
+	signatures to deal with string pointer vectors instead of string vectors.
+	* plugin/icedteanp/IcedTeaPluginUtils.cc
+	(stringToJSID): Added another signature that receives a string pointer.
+	(strSplit): Return string pointer vector instead of string vector.
+	(getUTF8String): Change signature to receive string pointer vector instead
+	of string vector. Update function accordingly.
+	(getUTF16LEString): Same. 
+	(subscribe): Make subscription atomic.
+	(unSubscribe): Make unsubscription atomic, bound to same lock as
+	subscribe().
+	(post): Make list iteration and processing atomic, bound to same lock as
+	subscribe and unSubscribe.
+	* plugin/icedteanp/IcedTeaPluginUtils.h: Added new signature for
+	stringToJSID and updated signatures for strSplit, getUTF8String and
+	getUTF16LEString.
+	* plugin/icedteanp/IcedTeaScriptablePluginObject.cc
+	(IcedTeaScriptableJavaPackageObject::deAllocate): Implemented method.
+	(IcedTeaScriptableJavaPackageObject::invalidate): Same.
+	(IcedTeaScriptableJavaObject::deAllocate): Same.
+	(IcedTeaScriptableJavaObject::invalidate): Same.
+
 2010-04-04  Matthias Klose  <doko@ubuntu.com>
 
 	* configure.ac: Check for shared LLVM library.
--- a/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc	Fri Jun 04 19:45:32 2010 +0100
+++ b/plugin/icedteanp/IcedTeaJavaRequestProcessor.cc	Tue Apr 06 14:17:02 2010 -0400
@@ -60,21 +60,21 @@
 {
 
 	// Anything we are waiting for _MUST_ have and instance id and reference #
-	std::vector<std::string>* message_parts = IcedTeaPluginUtilities::strSplit(message, " ");
+	std::vector<std::string*>* message_parts = IcedTeaPluginUtilities::strSplit(message, " ");
 
-	IcedTeaPluginUtilities::printStringVector("JavaRequest::newMessageOnBus:", message_parts);
+	IcedTeaPluginUtilities::printStringPtrVector("JavaRequest::newMessageOnBus:", message_parts);
 
-	if (message_parts->at(0) == "context" && message_parts->at(2) == "reference")
-		if (atoi(message_parts->at(1).c_str()) == this->instance && atoi(message_parts->at(3).c_str()) == this->reference)
+	if (*(message_parts->at(0)) == "context" && *(message_parts->at(2)) == "reference")
+		if (atoi(message_parts->at(1)->c_str()) == this->instance && atoi(message_parts->at(3)->c_str()) == this->reference)
 		{
 			// Gather the results
 
 			// Let's get errors out of the way first
-			if (message_parts->at(4).find("Error") == 0)
+			if (!message_parts->at(4)->find("Error"))
 			{
 				for (int i=5; i < message_parts->size(); i++)
 				{
-					result->error_msg->append(message_parts->at(i));
+					result->error_msg->append(*(message_parts->at(i)));
 					result->error_msg->append(" ");
 				}
 
@@ -83,78 +83,78 @@
 				result->error_occurred = true;
 				result_ready = true;
 			}
-			else if (message_parts->at(4) == "GetStringUTFChars" ||
-			         message_parts->at(4) == "GetToStringValue")
+			else if (!message_parts->at(4)->find("GetStringUTFChars") ||
+			         !message_parts->at(4)->find("GetToStringValue"))
 			{
 				// first item is length, and it is radix 10
-				int length = strtol(message_parts->at(5).c_str(), NULL, 10);
+				int length = strtol(message_parts->at(5)->c_str(), NULL, 10);
 
 				IcedTeaPluginUtilities::getUTF8String(length, 6 /* start at */, message_parts, result->return_string);
 				result_ready = true;
 			}
-			else if (message_parts->at(4) == "GetStringChars") // GetStringChars (UTF-16LE/UCS-2)
+			else if (!message_parts->at(4)->find("GetStringChars")) // GetStringChars (UTF-16LE/UCS-2)
 			{
 				// first item is length, and it is radix 10
-				int length = strtol(message_parts->at(5).c_str(), NULL, 10);
+				int length = strtol(message_parts->at(5)->c_str(), NULL, 10);
 
 				IcedTeaPluginUtilities::getUTF16LEString(length, 6 /* start at */, message_parts, result->return_wstring);
 				result_ready = true;
-			} else if ((message_parts->at(4) == "FindClass") ||
-			        (message_parts->at(4) == "GetClassName") ||
-			        (message_parts->at(4) == "GetClassID") ||
-			        (message_parts->at(4) == "GetMethodID") ||
-			        (message_parts->at(4) == "GetStaticMethodID") ||
-			        (message_parts->at(4) == "GetObjectClass") ||
-                    (message_parts->at(4) == "NewObject") ||
-                    (message_parts->at(4) == "NewStringUTF") ||
-                    (message_parts->at(4) == "HasPackage") ||
-                    (message_parts->at(4) == "HasMethod") ||
-                    (message_parts->at(4) == "HasField") ||
-                    (message_parts->at(4) == "GetStaticFieldID") ||
-                    (message_parts->at(4) == "GetFieldID") ||
-                    (message_parts->at(4) == "GetJavaObject") ||
-                    (message_parts->at(4) == "IsInstanceOf") ||
-                    (message_parts->at(4) == "NewArray"))
+			} else if (!message_parts->at(4)->find("FindClass") ||
+			           !message_parts->at(4)->find("GetClassName") ||
+			           !message_parts->at(4)->find("GetClassID") ||
+			           !message_parts->at(4)->find("GetMethodID") ||
+			           !message_parts->at(4)->find("GetStaticMethodID") ||
+			           !message_parts->at(4)->find("GetObjectClass") ||
+			           !message_parts->at(4)->find("NewObject") ||
+			           !message_parts->at(4)->find("NewStringUTF") ||
+			           !message_parts->at(4)->find("HasPackage") ||
+			           !message_parts->at(4)->find("HasMethod") ||
+			           !message_parts->at(4)->find("HasField") ||
+			           !message_parts->at(4)->find("GetStaticFieldID") ||
+			           !message_parts->at(4)->find("GetFieldID") ||
+			           !message_parts->at(4)->find("GetJavaObject") ||
+			           !message_parts->at(4)->find("IsInstanceOf") ||
+			           !message_parts->at(4)->find("NewArray"))
 			{
-				result->return_identifier = atoi(message_parts->at(5).c_str());
-				result->return_string->append(message_parts->at(5)); // store it as a string as well, for easy access
+				result->return_identifier = atoi(message_parts->at(5)->c_str());
+				result->return_string->append(*(message_parts->at(5))); // store it as a string as well, for easy access
 				result_ready = true;
-			}  else if ((message_parts->at(4) == "DeleteLocalRef") ||
-		                (message_parts->at(4) == "NewGlobalRef"))
+			}  else if (!message_parts->at(4)->find("DeleteLocalRef") ||
+			            !message_parts->at(4)->find("NewGlobalRef"))
 			{
 			    result_ready = true; // nothing else to do
-			} else if ((message_parts->at(4) == "CallMethod") ||
-					   (message_parts->at(4) == "CallStaticMethod") ||
-					   (message_parts->at(4) == "GetField") ||
-					   (message_parts->at(4) == "GetStaticField") ||
-					   (message_parts->at(4) == "GetValue") ||
-	                   (message_parts->at(4) == "GetObjectArrayElement"))
+			} else if (!message_parts->at(4)->find("CallMethod") ||
+			           !message_parts->at(4)->find("CallStaticMethod") ||
+			           !message_parts->at(4)->find("GetField") ||
+			           !message_parts->at(4)->find("GetStaticField") ||
+			           !message_parts->at(4)->find("GetValue") ||
+			           !message_parts->at(4)->find("GetObjectArrayElement"))
 			{
 
-			    if (message_parts->at(5) == "literalreturn")
+			    if (!message_parts->at(5)->find("literalreturn"))
                 {
 			        // literal returns don't have a corresponding jni id
 			        result->return_identifier = 0;
-			        result->return_string->append(message_parts->at(5));
+			        result->return_string->append(*(message_parts->at(5)));
 			        result->return_string->append(" ");
-			        result->return_string->append(message_parts->at(6));
+			        result->return_string->append(*(message_parts->at(6)));
 
                 } else
 			    {
                     // Else it is a complex object
 
-			        result->return_identifier = atoi(message_parts->at(5).c_str());
-			        result->return_string->append(message_parts->at(5)); // store it as a string as well, for easy access
+			        result->return_identifier = atoi(message_parts->at(5)->c_str());
+			        result->return_string->append(*(message_parts->at(5))); // store it as a string as well, for easy access
 			    }
 
 				result_ready = true;
-			} else if ((message_parts->at(4) == "GetArrayLength"))
+			} else if (!message_parts->at(4)->find("GetArrayLength"))
             {
 			    result->return_identifier = 0; // length is not an "identifier"
-			    result->return_string->append(message_parts->at(5));
+			    result->return_string->append(*(message_parts->at(5)));
 			    result_ready = true;
-            } else if ((message_parts->at(4) == "SetField") ||
-                       (message_parts->at(4) == "SetObjectArrayElement"))
+            } else if (!message_parts->at(4)->find("SetField") ||
+                       !message_parts->at(4)->find("SetObjectArrayElement"))
             {
 
                 // nothing to do
@@ -163,13 +163,12 @@
                 result_ready = true;
             }
 
-			delete message_parts;
+            IcedTeaPluginUtilities::freeStringPtrVector(message_parts);
 			return true;
 		}
 
-	delete message_parts;
+    IcedTeaPluginUtilities::freeStringPtrVector(message_parts);
 	return false;
-
 }
 
 /**
--- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc	Fri Jun 04 19:45:32 2010 +0100
+++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.cc	Tue Apr 06 14:17:02 2010 -0400
@@ -50,7 +50,7 @@
 // Initialize static members used by the queue processing framework
 pthread_mutex_t message_queue_mutex = PTHREAD_MUTEX_INITIALIZER;
 pthread_mutex_t syn_write_mutex = PTHREAD_MUTEX_INITIALIZER;
-std::vector< std::vector<std::string>* >* message_queue = new std::vector< std::vector<std::string>* >();
+std::vector< std::vector<std::string*>* >* message_queue = new std::vector< std::vector<std::string*>* >();
 
 /**
  * PluginRequestProcessor constructor.
@@ -91,36 +91,36 @@
 {
     PLUGIN_DEBUG_1ARG("PluginRequestProcessor processing %s\n", message);
 
-    std::string type;
-    std::string command;
+    std::string* type;
+    std::string* command;
     int counter = 0;
 
-    std::vector<std::string>* message_parts = IcedTeaPluginUtilities::strSplit(message, " ");
+    std::vector<std::string*>* message_parts = IcedTeaPluginUtilities::strSplit(message, " ");
 
-    std::vector<std::string>::iterator the_iterator;
+    std::vector<std::string*>::iterator the_iterator;
     the_iterator = message_parts->begin();
 
-    IcedTeaPluginUtilities::printStringVector("PluginRequestProcessor::newMessageOnBus:", message_parts);
+    IcedTeaPluginUtilities::printStringPtrVector("PluginRequestProcessor::newMessageOnBus:", message_parts);
 
     type = message_parts->at(0);
     command = message_parts->at(4);
 
-    if (type == "instance")
+    if (!type->find("instance"))
     {
-        if (command == "GetWindow")
+        if (!command->find("GetWindow"))
         {
             // Window can be queried from the main thread only. And this call
             // returns immediately, so we do it in the same thread.
             this->sendWindow(message_parts);
             return true;
-        } else if (command == "GetMember" ||
-                   command == "SetMember" ||
-                   command == "ToString"  ||
-                   command == "Call"      ||
-                   command == "GetSlot"   ||
-                   command == "SetSlot"   ||
-                   command == "Eval"      ||
-                   command == "Finalize")
+        } else if (!command->find("GetMember") ||
+                   !command->find("SetMember") ||
+                   !command->find("ToString") ||
+                   !command->find("Call") ||
+                   !command->find("GetSlot") ||
+                   !command->find("SetSlot") ||
+                   !command->find("Eval") ||
+                   !command->find("Finalize"))
         {
 
             // Update queue synchronously
@@ -136,7 +136,7 @@
 
     }
 
-    delete message_parts;
+    IcedTeaPluginUtilities::freeStringPtrVector(message_parts);
 
     // If we got here, it means we couldn't process the message. Let the caller know.
     return false;
@@ -149,10 +149,10 @@
  */
 
 void
-PluginRequestProcessor::sendWindow(std::vector<std::string>* message_parts)
+PluginRequestProcessor::sendWindow(std::vector<std::string*>* message_parts)
 {
-    std::string type;
-    std::string command;
+    std::string* type;
+    std::string* command;
     int reference;
     std::string response = std::string();
     std::string window_ptr_str = std::string();
@@ -161,8 +161,8 @@
     int id;
 
     type = message_parts->at(0);
-    id = atoi(message_parts->at(1).c_str());
-    reference = atoi(message_parts->at(3).c_str());
+    id = atoi(message_parts->at(1)->c_str());
+    reference = atoi(message_parts->at(3)->c_str());
     command = message_parts->at(4);
 
     NPP instance;
@@ -182,8 +182,6 @@
 
     plugin_to_java_bus->post(response.c_str());
 
-    delete message_parts;
-
     // store the instance pointer for future reference
     IcedTeaPluginUtilities::storeInstanceID(variant, instance);
 }
@@ -195,7 +193,7 @@
  */
 
 void
-PluginRequestProcessor::eval(std::vector<std::string>* message_parts)
+PluginRequestProcessor::eval(std::vector<std::string*>* message_parts)
 {
     JavaRequestProcessor request_processor = JavaRequestProcessor();
     JavaResultData* java_result;
@@ -209,11 +207,11 @@
     std::string return_type = std::string();
     int id;
 
-    reference = atoi(message_parts->at(3).c_str());
+    reference = atoi(message_parts->at(3)->c_str());
     window_ptr = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(message_parts->at(5));
     instance = IcedTeaPluginUtilities::getInstanceFromMemberPtr(window_ptr);
 
-    java_result = request_processor.getString(message_parts->at(6));
+    java_result = request_processor.getString(*(message_parts->at(6)));
     CHECK_JAVA_RESULT(java_result);
     script.append(*(java_result->return_string));
 
@@ -250,9 +248,6 @@
     response += result_variant_jniid;
 
     plugin_to_java_bus->post(response.c_str());
-
-    delete message_parts;
-
 }
 
 /**
@@ -262,10 +257,10 @@
  */
 
 void
-PluginRequestProcessor::call(std::vector<std::string>* message_parts)
+PluginRequestProcessor::call(std::vector<std::string*>* message_parts)
 {
     NPP instance;
-    std::string window_ptr_str;
+    std::string* window_ptr_str;
     NPVariant* window_ptr;
     int reference;
     std::string window_function_name;
@@ -276,7 +271,7 @@
     JavaRequestProcessor java_request = JavaRequestProcessor();
     JavaResultData* java_result;
 
-    reference = atoi(message_parts->at(3).c_str());
+    reference = atoi(message_parts->at(3)->c_str());
 
     // window
     window_ptr_str = message_parts->at(5);
@@ -286,14 +281,14 @@
     instance = IcedTeaPluginUtilities::getInstanceFromMemberPtr(window_ptr);
 
     // function name
-    java_result = java_request.getString(message_parts->at(6));
+    java_result = java_request.getString(*(message_parts->at(6)));
     CHECK_JAVA_RESULT(java_result);
     window_function_name.append(*(java_result->return_string));
 
     // arguments
     for (int i=7; i < message_parts->size(); i++)
     {
-        arg_ids.push_back(message_parts->at(i));
+        arg_ids.push_back(*(message_parts->at(i)));
     }
 
     // determine arguments
@@ -366,7 +361,7 @@
  * @param message_parts The request message.
  */
 void
-PluginRequestProcessor::sendString(std::vector<std::string>* message_parts)
+PluginRequestProcessor::sendString(std::vector<std::string*>* message_parts)
 {
     std::string variant_ptr;
     NPVariant* variant;
@@ -375,8 +370,8 @@
     int reference;
     std::string response = std::string();
 
-    reference = atoi(message_parts->at(3).c_str());
-    variant_ptr = message_parts->at(5);
+    reference = atoi(message_parts->at(3)->c_str());
+    variant_ptr = *(message_parts->at(5));
 
     variant = (NPVariant*) IcedTeaPluginUtilities::stringToJSID(variant_ptr);
     AsyncCallThreadData thread_data = AsyncCallThreadData();
@@ -410,7 +405,6 @@
     plugin_to_java_bus->post(response.c_str());
 
     cleanup:
-    delete message_parts;
 
     pthread_mutex_lock(&tc_mutex);
     thread_count--;
@@ -424,7 +418,7 @@
  */
 
 void
-PluginRequestProcessor::setMember(std::vector<std::string>* message_parts)
+PluginRequestProcessor::setMember(std::vector<std::string*>* message_parts)
 {
     std::string propertyNameID;
     std::string value = std::string();
@@ -438,28 +432,28 @@
     JavaRequestProcessor java_request = JavaRequestProcessor();
     JavaResultData* java_result;
 
-    IcedTeaPluginUtilities::printStringVector("PluginRequestProcessor::_setMember - ", message_parts);
+    IcedTeaPluginUtilities::printStringPtrVector("PluginRequestProcessor::_setMember - ", message_parts);
 
-    reference = atoi(message_parts->at(3).c_str());
+    reference = atoi(message_parts->at(3)->c_str());
 
-    member = (NPVariant*) (IcedTeaPluginUtilities::stringToJSID(message_parts->at(5)));
-    propertyNameID = message_parts->at(6);
+    member = (NPVariant*) (IcedTeaPluginUtilities::stringToJSID(*(message_parts->at(5))));
+    propertyNameID = *(message_parts->at(6));
 
-    if (message_parts->at(7) == "literalreturn")
+    if (*(message_parts->at(7)) == "literalreturn")
     {
-        value.append(message_parts->at(7));
+        value.append(*(message_parts->at(7)));
         value.append(" ");
-        value.append(message_parts->at(8));
+        value.append(*(message_parts->at(8)));
     } else
     {
-        value.append(message_parts->at(7));
+        value.append(*(message_parts->at(7)));
     }
 
     instance = IcedTeaPluginUtilities::getInstanceFromMemberPtr(member);
 
-    if (message_parts->at(4) == "SetSlot")
+    if (*(message_parts->at(4)) == "SetSlot")
     {
-        property_identifier = browser_functions.getintidentifier(atoi(message_parts->at(6).c_str()));
+        property_identifier = browser_functions.getintidentifier(atoi(message_parts->at(6)->c_str()));
     } else
     {
         java_result = java_request.getString(propertyNameID);
@@ -504,7 +498,6 @@
     plugin_to_java_bus->post(response.c_str());
 
     cleanup:
-    delete message_parts;
 
     // property_name, type and value are deleted by _setMember
     pthread_mutex_lock(&tc_mutex);
@@ -524,7 +517,7 @@
  */
 
 void
-PluginRequestProcessor::sendMember(std::vector<std::string>* message_parts)
+PluginRequestProcessor::sendMember(std::vector<std::string*>* message_parts)
 {
     // member initialization
     std::vector<std::string> args;
@@ -545,17 +538,17 @@
     int reference;
 
     // debug printout of parent thread data
-    IcedTeaPluginUtilities::printStringVector("PluginRequestProcessor::getMember:", message_parts);
+    IcedTeaPluginUtilities::printStringPtrVector("PluginRequestProcessor::getMember:", message_parts);
 
-    reference = atoi(message_parts->at(3).c_str());
+    reference = atoi(message_parts->at(3)->c_str());
 
     // store info in local variables for easy access
-    instance_id = atoi(message_parts->at(1).c_str());
+    instance_id = atoi(message_parts->at(1)->c_str());
     parent_ptr = (NPVariant*) (IcedTeaPluginUtilities::stringToJSID(message_parts->at(5)));
-    member_id += message_parts->at(6);
+    member_id.append(*(message_parts->at(6)));
 
     /** Request data from Java if necessary **/
-    if (message_parts->at(4) == "GetSlot")
+    if (*(message_parts->at(4)) == "GetSlot")
     {
         member_identifier = browser_functions.getintidentifier(atoi(member_id.c_str()));
     } else
@@ -647,7 +640,7 @@
 
 
     IcedTeaPluginUtilities::constructMessagePrefix(0, reference, &response);
-    if (message_parts->at(2) == "GetSlot")
+    if (*(message_parts->at(2)) == "GetSlot")
     {
         response.append(" JavaScriptGetMember ");
     } else {
@@ -659,7 +652,6 @@
 
     // Now be a good citizen and help keep the heap free of garbage
     cleanup:
-    delete message_parts; // message_parts vector that was allocated by the caller
 
     pthread_mutex_lock(&tc_mutex);
     thread_count--;
@@ -673,20 +665,20 @@
  */
 
 void
-PluginRequestProcessor::finalize(std::vector<std::string>* message_parts)
+PluginRequestProcessor::finalize(std::vector<std::string*>* message_parts)
 {
-    std::string type;
-    std::string command;
+    std::string* type;
+    std::string* command;
     int reference;
     std::string response = std::string();
-    std::string variant_ptr_str = std::string();
+    std::string* variant_ptr_str;
     NPVariant* variant_ptr;
     NPObject* window_ptr;
     int id;
 
     type = message_parts->at(0);
-    id = atoi(message_parts->at(1).c_str());
-    reference = atoi(message_parts->at(3).c_str());
+    id = atoi(message_parts->at(1)->c_str());
+    reference = atoi(message_parts->at(3)->c_str());
     variant_ptr_str = message_parts->at(5);
 
     NPP instance;
@@ -707,9 +699,6 @@
     response += " JavaScriptFinalize";
 
     plugin_to_java_bus->post(response.c_str());
-
-    delete message_parts;
-
 }
 
 
@@ -718,7 +707,7 @@
 {
 
     PluginRequestProcessor* processor = (PluginRequestProcessor*) data;
-    std::vector<std::string>* message_parts = NULL;
+    std::vector<std::string*>* message_parts = NULL;
     std::string command;
     pthread_mutex_t wait_mutex = PTHREAD_MUTEX_INITIALIZER; // This is needed for API compat. and is unused
 
@@ -736,7 +725,7 @@
 
         if (message_parts)
         {
-            command = message_parts->at(4);
+            command = *(message_parts->at(4));
 
             if (command == "GetMember")
             {
@@ -783,9 +772,11 @@
             } else
             {
                 // Nothing matched
-                IcedTeaPluginUtilities::printStringVector("Error: Unable to process message: ", message_parts);
+                IcedTeaPluginUtilities::printStringPtrVector("Error: Unable to process message: ", message_parts);
+            }
 
-            }
+            // Free memory for message_parts
+            IcedTeaPluginUtilities::freeStringPtrVector(message_parts);
 
         } else
         {
--- a/plugin/icedteanp/IcedTeaPluginRequestProcessor.h	Fri Jun 04 19:45:32 2010 +0100
+++ b/plugin/icedteanp/IcedTeaPluginRequestProcessor.h	Tue Apr 06 14:17:02 2010 -0400
@@ -96,7 +96,7 @@
 extern pthread_mutex_t syn_write_mutex;
 
 /* Queue for holding messages that get processed in a separate thread */
-extern std::vector< std::vector<std::string>* >* message_queue;
+extern std::vector< std::vector<std::string*>* >* message_queue;
 
 /**
  * Processes requests made TO the plugin (by java or anyone else)
@@ -112,7 +112,7 @@
     	void dispatch(void* func_ptr (void*), std::vector<std::string>* message, std::string* src);
 
     	/* Send main window pointer to Java */
-    	void sendWindow(std::vector<std::string>* message_parts);
+    	void sendWindow(std::vector<std::string*>* message_parts);
 
     	/* Stores the variant on java side */
     	void storeVariantInJava(NPVariant variant, std::string* result);
@@ -125,22 +125,22 @@
         virtual bool newMessageOnBus(const char* message);
 
         /* Send member ID to Java */
-        void sendMember(std::vector<std::string>* message_parts);
+        void sendMember(std::vector<std::string*>* message_parts);
 
         /* Set member to given value */
-        void setMember(std::vector<std::string>* message_parts);
+        void setMember(std::vector<std::string*>* message_parts);
 
         /* Send string value of requested object */
-        void sendString(std::vector<std::string>* message_parts);
+        void sendString(std::vector<std::string*>* message_parts);
 
         /* Evaluate the given script */
-        void eval(std::vector<std::string>* message_parts);
+        void eval(std::vector<std::string*>* message_parts);
 
         /* Evaluate the given script */
-        void call(std::vector<std::string>* message_parts);
+        void call(std::vector<std::string*>* message_parts);
 
         /* Decrements reference count for given object */
-        void finalize(std::vector<std::string>* message_parts);
+        void finalize(std::vector<std::string*>* message_parts);
 };
 
 #endif // __ICEDTEAPLUGINREQUESTPROCESSOR_H__
--- a/plugin/icedteanp/IcedTeaPluginUtils.cc	Fri Jun 04 19:45:32 2010 +0100
+++ b/plugin/icedteanp/IcedTeaPluginUtils.cc	Tue Apr 06 14:17:02 2010 -0400
@@ -188,6 +188,32 @@
 }
 
 /**
+ * Returns a void pointer from a string representation
+ *
+ * @param id_str The pointer to the string representation
+ * @return The pointer
+ */
+
+void*
+IcedTeaPluginUtilities::stringToJSID(std::string* id_str)
+{
+    void* ptr;
+    if (sizeof(void*) == sizeof(long long))
+    {
+        PLUGIN_DEBUG_2ARG("Casting (long long) \"%s\" -- %llu\n", id_str->c_str(), strtoull(id_str->c_str(), NULL, 0));
+        ptr = reinterpret_cast <void*> ((unsigned long long) strtoull(id_str->c_str(), NULL, 0));
+    } else
+    {
+        PLUGIN_DEBUG_2ARG("Casting (long) \"%s\" -- %lu\n", id_str->c_str(), strtoul(id_str->c_str(), NULL, 0));
+        ptr = reinterpret_cast <void*> ((unsigned long)  strtoul(id_str->c_str(), NULL, 0));
+    }
+
+    PLUGIN_DEBUG_1ARG("Casted: %p\n", ptr);
+
+    return ptr;
+}
+
+/**
  * Increments the global reference number and returns it.
  *
  * This function is thread-safe.
@@ -249,8 +275,9 @@
 {
 	if (v)
 	{
-		for (int i=0; i < v->size(); i++)
+		for (int i=0; i < v->size(); i++) {
 			delete v->at(i);
+		}
 
 		delete v;
 	}
@@ -265,10 +292,10 @@
  * @return A string vector containing the aplit components
  */
 
-std::vector<std::string>*
+std::vector<std::string*>*
 IcedTeaPluginUtilities::strSplit(const char* str, const char* delim)
 {
-	std::vector<std::string>* v = new std::vector<std::string>();
+	std::vector<std::string*>* v = new std::vector<std::string*>();
 	v->reserve(strlen(str)/2);
 	char* copy;
 
@@ -281,9 +308,11 @@
 
 	while (tok_ptr != NULL)
 	{
+	    // Allocation on heap since caller has no way to knowing how much will
+	    // be needed. Make sure caller cleans up!
 		std::string* s = new std::string();
 		s->append(tok_ptr);
-		v->push_back(*s);
+		v->push_back(s);
 		tok_ptr = strtok (NULL, " ");
 	}
 
@@ -308,12 +337,12 @@
  */
 
 void
-IcedTeaPluginUtilities::getUTF8String(int length, int begin, std::vector<std::string>* unicode_byte_array, std::string* result_unicode_str)
+IcedTeaPluginUtilities::getUTF8String(int length, int begin, std::vector<std::string*>* unicode_byte_array, std::string* result_unicode_str)
 {
 	result_unicode_str->clear();
 	result_unicode_str->reserve(unicode_byte_array->size()/2);
 	for (int i = begin; i < begin+length; i++)
-	    result_unicode_str->push_back((char) strtol(unicode_byte_array->at(i).c_str(), NULL, 16));
+	    result_unicode_str->push_back((char) strtol(unicode_byte_array->at(i)->c_str(), NULL, 16));
 
 	PLUGIN_DEBUG_2ARG("Converted UTF-8 string: %s. Length=%d\n", result_unicode_str->c_str(), result_unicode_str->length());
 }
@@ -367,7 +396,7 @@
  *        converted string is placed
  */
 void
-IcedTeaPluginUtilities::getUTF16LEString(int length, int begin, std::vector<std::string>* unicode_byte_array, std::wstring* result_unicode_str)
+IcedTeaPluginUtilities::getUTF16LEString(int length, int begin, std::vector<std::string*>* unicode_byte_array, std::wstring* result_unicode_str)
 {
 
 	wchar_t c;
@@ -377,8 +406,8 @@
 	result_unicode_str->clear();
 	for (int i = begin; i < begin+length; i+=2)
 	{
-		int low = strtol(unicode_byte_array->at(i).c_str(), NULL, 16);
-		int high = strtol(unicode_byte_array->at(i+1).c_str(), NULL, 16);
+		int low = strtol(unicode_byte_array->at(i)->c_str(), NULL, 16);
+		int high = strtol(unicode_byte_array->at(i+1)->c_str(), NULL, 16);
 
         c = ((high << 8) | low);
 
@@ -963,9 +992,9 @@
     // Applets may initialize in parallel. So lock before pushing.
 
 	PLUGIN_DEBUG_2ARG("Subscribing %p to bus %p\n", b, this);
-//    pthread_mutex_lock(&subscriber_mutex);
+    pthread_mutex_lock(&subscriber_mutex);
     subscribers.push_back(b);
-//    pthread_mutex_unlock(&subscriber_mutex);
+    pthread_mutex_unlock(&subscriber_mutex);
 }
 
 /**
@@ -979,9 +1008,9 @@
     // Applets may initialize in parallel. So lock before pushing.
 
 	PLUGIN_DEBUG_2ARG("Un-subscribing %p from bus %p\n", b, this);
-//    pthread_mutex_lock(&subscriber_mutex);
+    pthread_mutex_lock(&subscriber_mutex);
     subscribers.remove(b);
-//    pthread_mutex_unlock(&subscriber_mutex);
+    pthread_mutex_unlock(&subscriber_mutex);
 }
 
 /**
@@ -999,7 +1028,7 @@
 	strcpy(msg, message);
 
 	PLUGIN_DEBUG_1ARG("Trying to lock %p...\n", &msg_queue_mutex);
-//    pthread_mutex_lock(&msg_queue_mutex);
+	pthread_mutex_lock(&subscriber_mutex);
 
     PLUGIN_DEBUG_1ARG("Message %s received on bus. Notifying subscribers.\n", msg);
 
@@ -1009,7 +1038,7 @@
     	message_consumed = ((BusSubscriber*) *i)->newMessageOnBus(msg);
     }
 
-//    pthread_mutex_unlock(&msg_queue_mutex);
+    pthread_mutex_unlock(&subscriber_mutex);
 
     if (!message_consumed)
     	PLUGIN_DEBUG_1ARG("Warning: No consumer found for message %s\n", msg);
--- a/plugin/icedteanp/IcedTeaPluginUtils.h	Fri Jun 04 19:45:32 2010 +0100
+++ b/plugin/icedteanp/IcedTeaPluginUtils.h	Tue Apr 06 14:17:02 2010 -0400
@@ -210,6 +210,7 @@
 
     	/* Converts the given string representation to a pointer */
     	static void* stringToJSID(std::string id_str);
+    	static void* stringToJSID(std::string* id_str);
 
     	/* Increments reference count and returns it */
     	static int getReference();
@@ -224,12 +225,12 @@
     	static void freeStringPtrVector(std::vector<std::string*>* v);
 
     	/* Splits the given string based on the delimiter provided */
-    	static std::vector<std::string>* strSplit(const char* str,
+    	static std::vector<std::string*>* strSplit(const char* str,
     			                                  const char* delim);
 
     	/* Converts given unicode integer byte array to UTF8 string  */
     	static void getUTF8String(int length, int begin,
-    			std::vector<std::string>* unicode_byte_array,
+    			std::vector<std::string*>* unicode_byte_array,
     			std::string* result_unicode_str);
 
     	/* Converts given UTF8 string to unicode integer byte array */
@@ -238,7 +239,7 @@
 
     	/* Converts given unicode integer byte array to UTF16LE/UCS-2 string */
     	static void getUTF16LEString(int length, int begin,
-    			std::vector<std::string>* unicode_byte_array,
+    			std::vector<std::string*>* unicode_byte_array,
     			std::wstring* result_unicode_str);
 
     	/* Prints contents of given string vector */
--- a/plugin/icedteanp/IcedTeaScriptablePluginObject.cc	Fri Jun 04 19:45:32 2010 +0100
+++ b/plugin/icedteanp/IcedTeaScriptablePluginObject.cc	Tue Apr 06 14:17:02 2010 -0400
@@ -197,13 +197,13 @@
 void
 IcedTeaScriptableJavaPackageObject::deAllocate(NPObject *npobj)
 {
-	printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::deAllocate %p\n", npobj);
+    browser_functions.releaseobject(npobj);
 }
 
 void
 IcedTeaScriptableJavaPackageObject::invalidate(NPObject *npobj)
 {
-	printf ("** Unimplemented: IcedTeaScriptableJavaPackageObject::invalidate %p\n", npobj);
+	// nothing to do for these
 }
 
 bool
@@ -491,13 +491,12 @@
 void
 IcedTeaScriptableJavaObject::deAllocate(NPObject *npobj)
 {
-	printf ("** Unimplemented: IcedTeaScriptableJavaObject::deAllocate %p\n", npobj);
+	browser_functions.releaseobject(npobj);
 }
 
 void
 IcedTeaScriptableJavaObject::invalidate(NPObject *npobj)
 {
-	printf ("** Unimplemented: IcedTeaScriptableJavaObject::invalidate %p\n", npobj);
 	IcedTeaPluginUtilities::removeInstanceID(npobj);
 
 	std::string obj_key = std::string();