File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes memory limit crossed (assignment) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "memory limit crossed (assignment)" Watch "memory limit crossed (assignment)" New topic

memory limit crossed (assignment)

Muhammad Salman

Joined: Apr 11, 2012
Posts: 7

I have an assignment in which I have to create a program which decodea message. As an input I am given a file with keys and messages. The file format is

no of key/message pairs

The message I have is always lowercase string seperated by spaces, for example : hello world. The key I am provided it always integer, for example : 1595.
Now, what I have to do here is that I have to decode and the logic for that is that I have to shift the letters in the message by the given number and I have to move from left to right and then right to left for the number. For example : considering the above key and the message

h+1=i, e+5=j, l+9=u, l+5=q

Now that we used all the digits, we do it again from right to left:

o+5=t, the space is discarded, w+9=f, o+5=t, r+1=s

we repeat the process, starting from left to right:

l+1=m, d+5=i

The result is: ijuqt ftsmi.

So, i achieve this result but my program fails because it exceeds the memory limit. Below is my program if someone can help me I would be grateful
Claude Moore
Ranch Hand

Joined: Jun 24, 2005
Posts: 720

What do you mean with "program terminates because exceedes memory limit" ? Do you have a Stack Overflow error or and Heap Memory error ? (I don't remember exact names of these exceptions, sorry)

Apparently I cannot see in your code possibile endless loops or endless recursion calls to get such errors, at least if number of tests is enough small...
Luan Cestari
Ranch Hand

Joined: Feb 07, 2010
Posts: 163

Which exception do you get running this program?

I posted some information that might help you:

Please, visit me for some cool tech post at
I agree. Here's the link:
subject: memory limit crossed (assignment)
It's not a secret anymore!