Monday, April 15, 2019

AWS Lamdba: Exception in thread "main" java.lang.Error: java.lang.OutOfMemoryError: Metaspace

Execution of newly created Lambda gives below error

Exception in thread "main" java.lang.Error: java.lang.OutOfMemoryError: Metaspace

Bydefault the Memory allocated to Lambda is 128MB this needs to be increased

Solution:









Navigate to your Lambda in AWS and update the Basic setting increase the Memory and test it out




Saturday, March 30, 2019

JSON Serialization and Deserialization

JSON is a format that encodes objects in a string. Serialization means to convert an object into that string, and deserialization is its inverse operation.
When transmitting data or storing them in a file, the data are required to be byte strings, but complex objects are seldom in this format. Serialization can convert these complex objects into byte strings for such use. After the byte strings are transmitted, the receiver will have to recover the original object from the byte string. This is known as deserialization.
Say, you have an object
{foo: [1, 4, 7, 10], bar: "baz"}
serializing into JSON will convert it into a string:
'{"foo":[1,4,7,10],"bar":"baz"}'
which can be stored or sent through wire to anywhere. The receiver can then deserialize this string to get back the original object. {foo: [1, 4, 7, 10], bar: "baz"}.