Friday 15 February 2013

algorithm - How do I minimize the amount of memory needed for a fixed allocation scheme? -


The following image assumes the life span required for 16 different memory blocks:

< Img src = "Https://i.stack.imgur.com/KgysZ.png" alt = "Enter image details here">

What I'm essentially searching for is that many < << em> and lifetime [begin ] I , end i ) , to keep the total amount of time needed to keep them during the total time interval, and the N offset in total memory block for X, offset i .

A trivial non-optimal algorithm would be the following:

  int offset [N]; Offset [0] = 0; Int total_size = size [0]; For (int i = 1; i   

Our current algorithm is to sort the blocks from the size and then process them smallest from the largest, first finds the offset where the block is already "allocated" blocks It is essentially a greedy algorithm, so I think it would be possible to do better.

The algorithm needs to run only once at the beginning of the application, so it should not be extremely intense. The number of allocation is in the order of 10-50 and for our purposes time can be separated into approximately 50 fixed-size units.

start and end strong> time interval This is the total interval (t_min, t_max), when you are interested in, the time interval is some discrete and similar Divide into the interval. Let this be the length of the interval u It is basically the maximum resolution of your memory management (how many times you can claim free and / or memory blocks).

For each unit of time, determine whether the allocation ID needs memory and what size is required at all times, it s (t, id) Call The amount of s (t, id) on all the allocation ID is a limited amount of time that you need at any time. You can not do better than the maximum of this function, which fails to take into account the desire to keep all things without any charge at all times.

For each item you can use an approximate search. In fact, find the position of the location of all possible initial addresses for each memory block, for the total memory of small quantities Takes you, which you simulate the progress of time from t_min to t_max. An estimate may be that he likes to like the allocation, where the first large quantity was occupied, and with small contributions to the small part of the maximum use of the strategy. Has been placed at places. You can influence any strategy that is worse than the best, because the maximum amount of time a claim is monotonic with the strategy.

The estimated search method may be slow, but it seems that you care more about optimal memory usage with the runtime of the allocation algorithm.

No comments:

Post a Comment