memory-management

understanding python memory allocation and free up

╄→尐↘猪︶ㄣ 提交于 2020-01-01 09:39:18
问题 I recently came across this article about python memory allocation. In this page it describes the memory usage of python and in there there is an example showing deepcopy of list of integers. I did the benchmark myself on Python 2.7 Line # Mem usage Increment Line Contents ================================================ 4 28.051 MiB 0.000 MiB @profile 5 def function(): 6 59.098 MiB 31.047 MiB x = list(range(1000000)) # allocate a big list 7 107.273 MiB 48.176 MiB y = copy.deepcopy(x) 8 99

XNA: What is the point of Unload()?

别来无恙 提交于 2020-01-01 09:38:18
问题 XNA games have an Unload() method, where content is supposed to be unloaded. But what is the point of this? If all the content is being unloaded, then the game must be exiting, in which case everything would be garbage collected anyway, right? 回答1: As far as I understand it, it's not useful for any standard uses, since as you say the garbage collector deals with things for you. However, it's useful to have an event called when your game is exiting for many things. For example you could send a

Free unmanaged memory allocation from managed code

故事扮演 提交于 2020-01-01 09:34:06
问题 A .NET application calls C dll. The C code allocates memory for a char array and returns this array as result. The .NET applications gets this result as a string. The C code: extern "C" __declspec(dllexport) char* __cdecl Run() { char* result = (char*)malloc(100 * sizeof(char)); // fill the array with data return result; } The C# code: [DllImport("Unmanaged.dll")] private static extern string Run(); ... string result = Run(); // do something useful with the result and than leave it out of

can two process shared same GPU memory? (CUDA)

让人想犯罪 __ 提交于 2020-01-01 09:28:13
问题 In CPU world one can do it via memory map. Can similar things done for GPU? If two process can share a same CUDA context, I think it will be trivial - just pass GPU memory pointer around. Is it possible to share same CUDA context between two processes? Another possibility I could think of is to map device memory to a memory mapped host memory. Since it's memory mapped, it can be shared between two processes. Does this make sense / possible, and are there any overhead? 回答1: CUDA MPS

What happens when I call “delete” on an uninitialized pointer in C++?

笑着哭i 提交于 2020-01-01 09:23:07
问题 Let's say I declare a pointer of char, and call delete on it without having called new. Can this cause a problem? char* myptr; if (condition) //do something involving myptr = new char[SIZE]; else //do something that doesnt involve myptr //do more stuff delete[] myptr; I don't delete myptr under the if because another pointer in //do more stuff can point to it if condition was true. Obviously this works fine if condition was true because a "new" was called on myptr . Is deleting myptr bad if I

MATLAB takes a long time after last line of a function

孤街浪徒 提交于 2020-01-01 09:05:51
问题 I have a function that's taking a long time to run. When I profile it, I find that over half the time (26 out of 50 seconds) is not accounted for in the line by line timing breakdown, and I can show that the time is spent after the function finishes running but before it returns control by the following method: ts1 = tic; disp ('calling function'); functionCall(args); disp (['control returned to caller - ', num2str(toc(ts1))]); The first line of the function I call is ts2 = tic , and the last

MATLAB takes a long time after last line of a function

拈花ヽ惹草 提交于 2020-01-01 09:05:10
问题 I have a function that's taking a long time to run. When I profile it, I find that over half the time (26 out of 50 seconds) is not accounted for in the line by line timing breakdown, and I can show that the time is spent after the function finishes running but before it returns control by the following method: ts1 = tic; disp ('calling function'); functionCall(args); disp (['control returned to caller - ', num2str(toc(ts1))]); The first line of the function I call is ts2 = tic , and the last

Preventing Memory issues when handling large amounts of text

痞子三分冷 提交于 2020-01-01 09:04:30
问题 I have written a program which analyzes a project's source code and reports various issues and metrics based on the code. To analyze the source code, I load the code files that exist in the project's directory structure and analyze the code from memory. The code goes through extensive processing before it is passed to other methods to be analyzed further. The code is passed around to several classes when it is processed. The other day I was running it on one of the larger project my group has

allocate more than 1 GB memory on 32 bit XP

女生的网名这么多〃 提交于 2020-01-01 08:44:31
问题 I'v run into an odd problem, my process cannot allocate more than what seems to be slightly below 1 GiB. Windows Task Manager "Mem Usage" column shows values close to 1 GiB when my software gives a bad_alloc exception. Yes, i'v checked that the value passed to memory allocation is sensible. ( no race condition / corruption exists that would make this fail ). Yes, I need all this memory and there is no way around it. ( It's a buffer for images, which cannot be compressed any further ) I'm not

allocate more than 1 GB memory on 32 bit XP

寵の児 提交于 2020-01-01 08:44:04
问题 I'v run into an odd problem, my process cannot allocate more than what seems to be slightly below 1 GiB. Windows Task Manager "Mem Usage" column shows values close to 1 GiB when my software gives a bad_alloc exception. Yes, i'v checked that the value passed to memory allocation is sensible. ( no race condition / corruption exists that would make this fail ). Yes, I need all this memory and there is no way around it. ( It's a buffer for images, which cannot be compressed any further ) I'm not