# Buggy code
def _SetSerializerFormat(self, serializer_format):
    """Set the serializer format.

    Args:
      serializer_format: The storage serializer format.

    Raises:
      ValueError: if the serializer format is not supported.
    """
    if serializer_format == definitions.SERIALIZER_FORMAT_JSON:
        self._serializer_format_string = "json"

        self._analysis_report_serializer = json_serializer.JSONAnalysisReportSerializer
        self._event_object_serializer = json_serializer.JSONEventObjectSerializer
        self._event_tag_serializer = json_serializer.JSONEventTagSerializer
        self._pre_obj_serializer = json_serializer.JSONPreprocessObjectSerializer

    elif serializer_format == definitions.SERIALIZER_FORMAT_PROTOBUF:
        self._serializer_format_string = "proto"

        self._analysis_report_serializer = (
            protobuf_serializer.ProtobufAnalysisReportSerializer
        )
        self._event_object_serializer = (
            protobuf_serializer.ProtobufEventObjectSerializer
        )
        self._event_tag_serializer = protobuf_serializer.ProtobufEventTagSerializer
        self._pre_obj_serializer = (
            protobuf_serializer.ProtobufPreprocessObjectSerializer
        )

    else:
        raise ValueError(
            "Unsupported serializer format: {0:s}".format(serializer_format)
        )


# Traceback (MemoryError)
2015-10-14 12:58:53,921 [WARNING] (StorageWriter) PID:2384 <multi_process> Unhandled exception in storage writer (PID: 2384).
2015-10-14 12:58:53,926 [ERROR] (StorageWriter) PID:2384 <multi_process>
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/plaso/multi_processing/multi_process.py", line 1184, in _Main
self._storage_writer.WriteEventObjects()
File "/usr/lib/python2.7/dist-packages/plaso/lib/storage.py", line 1645, in WriteEventObjects
self._Close()
File "/usr/lib/python2.7/dist-packages/plaso/lib/storage.py", line 1675, in _Close
self._storage_file.Close()
File "/usr/lib/python2.7/dist-packages/plaso/lib/storage.py", line 874, in Close
self._FlushBuffer()
File "/usr/lib/python2.7/dist-packages/plaso/lib/storage.py", line 431, in _FlushBuffer
self._WriteStream(stream_name, b''.join(proto_str))
MemoryError
2015-10-14 12:59:17,026 [WARNING] (MainProcess) PID:2379 <multi_process> Killing process: Worker_00 (PID: 2385).
2015-10-14 12:59:17,026 [WARNING] (MainProcess) PID:2379 <multi_process> Killing process: Worker_04 (PID: 2392).
Processing completed with errors.

# Fixed code
def _SetSerializerFormat(self, serializer_format):
    """Set the serializer format.

    Args:
      serializer_format: the storage serializer format.

    Raises:
      ValueError: if the serializer format is not supported.
    """
    if serializer_format == definitions.SERIALIZER_FORMAT_JSON:
        self._serializer_format_string = "json"

        self._analysis_report_serializer = json_serializer.JSONAnalysisReportSerializer
        self._event_object_serializer = json_serializer.JSONEventObjectSerializer
        self._event_tag_serializer = json_serializer.JSONEventTagSerializer
        self._pre_obj_serializer = json_serializer.JSONPreprocessObjectSerializer

    elif serializer_format == definitions.SERIALIZER_FORMAT_PROTOBUF:
        self._serializer_format_string = "proto"

        self._analysis_report_serializer = (
            protobuf_serializer.ProtobufAnalysisReportSerializer
        )
        self._event_object_serializer = (
            protobuf_serializer.ProtobufEventObjectSerializer
        )
        self._event_tag_serializer = protobuf_serializer.ProtobufEventTagSerializer
        self._pre_obj_serializer = (
            protobuf_serializer.ProtobufPreprocessObjectSerializer
        )

    else:
        raise ValueError(
            "Unsupported serializer format: {0:s}".format(serializer_format)
        )