tagged [memory-management]

Most efficient way to append arrays in C#?

Most efficient way to append arrays in C#? I am pulling data out of an old-school ActiveX in the form of arrays of doubles. I don't initially know the final number of samples I will actually retrieve....

21 Nov at 14:21

object creation in stack

object creation in stack Can I create an object of my class in stack regarding .net and C#? For example: Now, here the object is created in heap. So, is there any way to create the object in stack mem...

28 Jul at 15:0

Python memory leaks

Python memory leaks I have a long-running script which, if let to run long enough, will consume all the memory on my system. Without going into details about the script, I have two questions: 1. Are t...

Retrieve CPU usage and memory usage of a single process on Linux?

Retrieve CPU usage and memory usage of a single process on Linux? I want to get the CPU and memory usage of a single process on Linux - I know the PID. Hopefully, I can get it every second and write i...

How is memory allocated for a static variable?

How is memory allocated for a static variable? In the below program: The `instanceVariable` will be stored inside the memory allocated for object instance. Where will the `staticVariable` be stored, i...

9 Mar at 14:16

Short-lived objects

Short-lived objects What is the overhead of generating a lot of temporary objects (i.e. for interim results) that "die young" (never promoted to the next generation during a garbage collection interva...

In Linux, how to tell how much memory processes are using?

In Linux, how to tell how much memory processes are using? I think I may have a memory leak in my LAMP application (memory gets used up, swap starts getting used, etc.). If I could see how much memory...

How do i free objects in C#

How do i free objects in C# Can anyone please tell me how I can free objects in C#? For example, I have an object: Thanks for all your help

9 Mar at 05:31

Can I reduce memory allocation by passing DateTime parameter by reference in c#?

Can I reduce memory allocation by passing DateTime parameter by reference in c#? In C#, is there any significant reduction in memory allocation when passing a DateTime reference as a parameter to a fu...

How to get memory usage at runtime using C++?

How to get memory usage at runtime using C++? I need to get the mem usage VIRT and RES at run time of my program and display them. What i tried so far: getrusage ([http://linux.die.net/man/2/getrusage...

18 May at 00:2

Can a local variable's memory be accessed outside its scope?

Can a local variable's memory be accessed outside its scope? I have the following code. ``` #include int * foo() { int a = 5; return &a; } int main() { int* p = foo(); std::cout

C# memory management: unsafe keyword and pointers

C# memory management: unsafe keyword and pointers What are the consequences (positive/negative) of using the keyword in to use pointers? For example, what becomes of garbage collection, what are the p...

Is there any benefit of using an Object Initializer?

Is there any benefit of using an Object Initializer? Are there any benefits in using C# object initializers? In C++ there are no references and everything is encapsulated inside an object so it makes ...

28 Feb at 07:32

How do malloc() and free() work?

How do malloc() and free() work? I want to know how `malloc` and `free` work. ``` int main() { unsigned char *p = (unsigned char*)malloc(4*sizeof(unsigned char)); memset(p,0,4); strcpy((char*)p,...

13 Apr at 02:42

Can you stop memory from being swapped to disk?

Can you stop memory from being swapped to disk? I was wondering if it was possible to prevent memory of a object (class or struct) from being swapped to disk? Edit: As for why I've been told some of t...

6 Oct at 21:8

How are String and Char types stored in memory in .NET?

How are String and Char types stored in memory in .NET? I'd need to store a language code string, such as "en", which will always contains 2 characters. Is it better to define the type as "String" or ...

Reasons for seeing high "% Time in GC" in Perf Mon

Reasons for seeing high "% Time in GC" in Perf Mon While monitoring our application in Perf Mon I noticed that the % of Time In GC is anywhere from 20 - 60% while our application is performing a long ...

9 Sep at 14:30

How can I get CPU usage and/or RAM usage of a *THREAD* in C# (managed code)?

How can I get CPU usage and/or RAM usage of a *THREAD* in C# (managed code)? I know how to get CPU usage and memory usage for a process, but I was wondering how to get it on a per-thread level. If the...

Freeing CUDA memory painfully slow

Freeing CUDA memory painfully slow I am allocating some float arrays (pretty large, ie 9,000,000 elements) on the GPU using `cudaMalloc((void**)&(storage->data), size * sizeof(float))`. In the end of ...

28 Jan at 23:14

How to deal with bad_alloc in C++?

How to deal with bad_alloc in C++? There is a method called `foo` that sometimes returns the following error: Is there a way that I can use a `try`-`catch` block to stop this error from terminating my...

14 May at 10:27

Explicit Event add/remove, misunderstood?

Explicit Event add/remove, misunderstood? I've been looking into memory management a lot recently and have been looking at how events are managed, now, I'm seeing the explicit add/remove syntax for th...

27 May at 18:48

How to list processes attached to a shared memory segment in linux?

How to list processes attached to a shared memory segment in linux? How do I determine what process is attached to a shared memory segment? ``` awagner@tree:/home/awagner$ ipcs -m ------ Shared Memory...

What causes memory fragmentation in .NET

What causes memory fragmentation in .NET I am using Red Gates ANTS memory profiler to debug a memory leak. It keeps warning me that: > Memory Fragmentation may be causing .NET to reserver too much fr...

Resources that have to be manually cleaned up in C#?

Resources that have to be manually cleaned up in C#? What resources have to be manually cleaned up in and what are the consequences of not doing so? For example, say I have the following code: If I do...

Singleton Destructors

Singleton Destructors Should Singleton objects that don't use instance/reference counters be considered memory leaks in C++? Without a counter that calls for explicit deletion of the singleton instanc...

8 Nov at 10:37