diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp
index 8276ec836a77399ed164ff02d4ec65a3286aafb5..f9624852843c6a41cd6b35ede7cd4d03a69ff88b 100755
--- a/indra/llcommon/llsd.cpp
+++ b/indra/llcommon/llsd.cpp
@@ -506,6 +506,8 @@ namespace
 
 		LLSD::array_iterator beginArray() { return mData.begin(); }
 		LLSD::array_iterator endArray() { return mData.end(); }
+		LLSD::reverse_array_iterator rbeginArray() { return mData.rbegin(); }
+		LLSD::reverse_array_iterator rendArray() { return mData.rend(); }
 		virtual LLSD::array_const_iterator beginArray() const { return mData.begin(); }
 		virtual LLSD::array_const_iterator endArray() const { return mData.end(); }
 
@@ -947,6 +949,9 @@ LLSD::array_iterator		LLSD::endArray()		{ return makeArray(impl).endArray(); }
 LLSD::array_const_iterator	LLSD::beginArray() const{ return safe(impl).beginArray(); }
 LLSD::array_const_iterator	LLSD::endArray() const	{ return safe(impl).endArray(); }
 
+LLSD::reverse_array_iterator	LLSD::rbeginArray()		{ return makeArray(impl).rbeginArray(); }
+LLSD::reverse_array_iterator	LLSD::rendArray()		{ return makeArray(impl).rendArray(); }
+
 namespace llsd
 {
 
diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h
index 5eb69059ac6e5f41e4f76504f6d081419652766f..a3792c1f9da3aaaa48b1023688cceca34af17f72 100755
--- a/indra/llcommon/llsd.h
+++ b/indra/llcommon/llsd.h
@@ -320,11 +320,15 @@ class LL_COMMON_API LLSD
 		
 		typedef std::vector<LLSD>::iterator			array_iterator;
 		typedef std::vector<LLSD>::const_iterator	array_const_iterator;
-		
+		typedef std::vector<LLSD>::reverse_iterator reverse_array_iterator;
+
 		array_iterator			beginArray();
 		array_iterator			endArray();
 		array_const_iterator	beginArray() const;
 		array_const_iterator	endArray() const;
+
+		reverse_array_iterator	rbeginArray();
+		reverse_array_iterator	rendArray();
 	//@}
 	
 	/** @name Type Testing */
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index a4a79d4d97f4f1837b16b436f277f18cd58c2cf3..2949d62a1a5d598fe868cb02527950979f64c66e 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -5822,6 +5822,17 @@
       <key>Value</key>
       <real>1.6</real>
     </map>
+    <key>MaxPersistentNotifications</key>
+    <map>
+      <key>Comment</key>
+      <string>Maximum amount of persistent notifications</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>S32</string>
+      <key>Value</key>
+      <real>250</real>
+    </map>
     <key>MaxSelectDistance</key>
     <map>
       <key>Comment</key>
diff --git a/indra/newview/llpersistentnotificationstorage.cpp b/indra/newview/llpersistentnotificationstorage.cpp
index 666f10df964ae036a076594ff40117b903704796..c5104d54f2547de3c372eec117269b574fb140b8 100755
--- a/indra/newview/llpersistentnotificationstorage.cpp
+++ b/indra/newview/llpersistentnotificationstorage.cpp
@@ -76,6 +76,14 @@ void LLPersistentNotificationStorage::saveNotifications()
 		}
 
 		data.append(notification->asLLSD(true));
+		if (data.size() >= gSavedSettings.getS32("MaxPersistentNotifications"))
+		{
+			llwarns << "Too many persistent notifications."
+					<< " Saved " << gSavedSettings.getS32("MaxPersistentNotifications") << " of " << history_channel->size()
+					<< " persistent notifications." << llendl;
+			break;
+		}
+
 	}
 
 	writeNotifications(output);
@@ -89,9 +97,6 @@ void LLPersistentNotificationStorage::loadNotifications()
 
 	LL_INFOS("LLPersistentNotificationStorage") << "start loading notifications" << LL_ENDL;
 
-	LLNotifications::instance().getChannel("Persistent")->
-		connectChanged(boost::bind(&LLPersistentNotificationStorage::onPersistentChannelChanged, this, _1));
-
 	LLSD input;
 	if (!readNotifications(input) ||input.isUndefined())
 	{
@@ -109,9 +114,9 @@ void LLPersistentNotificationStorage::loadNotifications()
 		findChannelByID(LLUUID(gSavedSettings.getString("NotificationChannelUUID"))));
 
 	LLNotifications& instance = LLNotifications::instance();
-
-	for (LLSD::array_const_iterator notification_it = data.beginArray();
-		notification_it != data.endArray();
+	S32 processed_notifications = 0;
+	for (LLSD::reverse_array_iterator notification_it = data.rbeginArray();
+		notification_it != data.rendArray();
 		++notification_it)
 	{
 		LLSD notification_params = *notification_it;
@@ -130,8 +135,16 @@ void LLPersistentNotificationStorage::loadNotifications()
 			// hide saved toasts so they don't confuse the user
 			notification_channel->hideToast(notification->getID());
 		}
+		++processed_notifications;
+		if (processed_notifications >= gSavedSettings.getS32("MaxPersistentNotifications"))
+		{
+			llwarns << "Too many persistent notifications."
+					<< " Processed " << gSavedSettings.getS32("MaxPersistentNotifications") << " of " << data.size() << " persistent notifications." << llendl;
+		    break;
+		}
 	}
-
+	LLNotifications::instance().getChannel("Persistent")->
+			connectChanged(boost::bind(&LLPersistentNotificationStorage::onPersistentChannelChanged, this, _1));
 	LL_INFOS("LLPersistentNotificationStorage") << "finished loading notifications" << LL_ENDL;
 }