Loop is taking too long to process

I am using following to code to arrange the array of contacts in sections (for e.g. contact with prefix "A" should show under "A" section). If there are contacts 4-5 hundred then it takes 20 sec to process. Can you please check what is issue here? ...
more »

2017-10-04 09:10 (2) Answers

C/C++: telling a program to cache information

The performance of many programs can plummet if the CPU cache miss ratio is too high. Using certain data structures helps the caching algorithm to decide what could be needed next. Arrays for example are easy to cache. Linked lists (C++ list) on the ...
more »

2017-09-17 11:09 (1) Answers

return C++ local string to another function

Here is my confusion. I think s1 and s2 are function local object instance of type string, we should not return function local scope object to outside. But it seems below code works, wondering why? vector<string> testString(){ vector<st...
more »

2017-09-16 06:09 (3) Answers

Cabal install criterion out of memory

I'm running on a container with 768MB ram and 512 MB swap space. I can't increase either of this. cabal install criterion always gives Failed during the building phase. The exception was: ExitFailure (-9) This may be due to an out-of-memory conditio...
more »

2017-09-11 03:09 (1) Answers

memory request Linux

I have a c program that makes memory request. After that run my program i use the free -g -t command to see the memory used. The program call to the malloc function, but it does not call the free function. For example: pointer=malloc(900000000*size...
more »

2017-09-10 21:09 (2) Answers

Why both stack and heap grows?

I write such code int a = 0; int b = 0; int *m = (int *)malloc(2* sizeof(int)); printf("%x, %x\n", &a, &b); printf("%x, %x", &m[0], &m[1]); and get result: 46372e18, 46372e1c d062ec20, d062ec24 Is not that that stack grow down ...
more »

2017-09-04 15:09 (5) Answers

Cache Custom Class with NSCache

I am trying to Cache my custom class so I can reload it when user is offline. I am new to Swift so I have been looking around and most people said use NSCache. I have used this method in my class but It doest work. let cache = NSCache<NSString, ...
more »

2017-09-01 19:09 (0) Answers

Memory overhead of typed arrays vs strings

I am trying to reduce the memory usage of a javascript web application that stores a lot of information in memory in the form of a large number of small strings. When I changed the code to use Uint8Array instead of String, I noticed that memory usage...
more »

2017-08-21 20:08 (2) Answers

How much memory should I use in my Java program?

I am making a Java program. It involves making a image with size up to 9933 * 14043 pixels (which is A0 size and 300 ppi). The image is 24 bit, so it would take up about 400mb of space. The BufferedImage class some how take more RAM than the bitmap'...
more »

2017-08-13 18:08 (1) Answers