Reputation: 1
I have a program that goes n^2 layers deep of recursion and mallocs a bunch of memory to concatenate char*s together. With a large enough n, the process just gets killed by the server (since it is consuming too much memory). How can I release this memory and still have my data?
It's mallocs look like
test = (char *)malloc(sizeof(char) * 256);
I need this data straight until the end of the program. How can I deal with this?
Upvotes: 0
Views: 554
Reputation: 108986
You can't. Once you release the memory the data is gone.
What you may be able to do is to make better use of the memory you have available. With the code you posted, I can't think of a way to help you manage the memory any better though
Upvotes: 1
Reputation: 76795
Without thinking about it deeper, why do you need all of the data in memory? Several things you need to do:
Upvotes: 0