Click here to Skip to main content
15,889,867 members
Everything / Memory

Memory

memory

Great Reads

by Dmitriy Gakh
Development in C# without care of resource consumption can lead to overloading the system. This article describes a case with large waste of memory and CPU time and how to avoid it.
by Gamil Yassin
Types of Artificial Neural Networks
by PFalkowski
The way of calculating amount of memory occupied by some object in C#.NET
by honey the codewitch
Some C++ magic to help cut down on heap abuse for simple scenarios

Latest Articles

by Ayush Vijaywargi
Enhancing Android app stability by integrating LeakCanary with RxJava for efficient memory leak detection and resolution.
by ToughDev
How to use NFS to transfer files between Windows and MS-DOS 6.22
by ToughDev
Retro68 GCC-based SDK for 68K Mac
by ToughDev
Fix high Windows memory usage caused by large metafile

All Articles

Sort by Title

Memory 

1 Oct 2012 by Mehdi Gholam
Is there any way to detect memory usage of a .net application while running and implement internal memory flushing/freeing (i.e. limit my application to use 500mb ram through configuration) obviously the freeing would be done by yourself.
1 Oct 2012 by Stephen Hewison
You can check the memory usage of any process:If it reaches a certain size you can dispose of unwanted objects and call garbage collection.System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();long memory = p.PrivateMemorySize64;if(memory > 500 * 1024 *...
9 Dec 2012 by Jackie00100
As the title says! can I force a method/function to run on an other process without going too much into assemblies/decompiling etc.?I'm having a app that is in need of doing some very heavy memory work with some graphic objects using GDI+, (up to ½-1 GB) so I want to have this to run in a...
9 Dec 2012 by Sergey Alexandrovich Kryukov
There is no such thing as "force" to run something to "run on a single process". Processes are totally under your control. If you don't create a process, it is not created by anything by itself. And using GC is not recommended.Your "without going too much into assemblies and stuff like that"...
13 Jul 2017 by The_Unknown_Member
Hi. Can someone explain me why I cant make my pointer point to address of an array ? int main() { char s[] = "string"; char *p = &s; return 0; } But this works: int main() { char s[] = "string"; char *p = s; return 0; } And also Can someone explain me how this for loop...
12 Jul 2017 by OriginalGriff
You can't do this: char s[] = "string"; char *p = &s; because the name of an array is a pointer to the first element of that array. So s is already a pointer to a char, so &s is a pointer to a pointer to a char. You would need to change the type of p to use the address of s: char s[] =...
24 Aug 2017 by The_Unknown_Member
Can someone explain me what does the right side (after the equals sign) means ? I am casting an integer literal to a pointer or what ? I am confused int *var = (int *)1234; What I have tried: Asking here in CodeProject.COM
24 Aug 2017 by Dave Kreskowiak
All this is doing is returning a pointer to memory address 1234, which in Windows will probably get you a security exception if you try to read what's there from your code.
19 Aug 2012 by Captain Price
I know some programming (C/C++, JAVA, Win32..), but I don't know advanced concepts of Computer Science. I just know the basics. This question is about memory management in Windows Operating Systems. You can see the problem by just observing. 1. Open a file using Notepad by double clicking a...
19 Aug 2012 by Christian Graus
As Wes said, the task manager is telling you how much RAM the process has allocated to it for use, not how much it is using. It is good for a vague idea, or to show a runaway process, but it's not accurate at the granularity you're wanting it to be.
19 Aug 2012 by Sergey Alexandrovich Kryukov
I can give you a more specific idea if you have problems with memory allocation, such as memory leak, of not-enough-memory problems. The type of product you need is called "memory debugger".You can find the one suitable for you from this...
28 Mar 2016 by Dmitriy Gakh
Intensive Big Data processing and Mobile Applications require fast calculations and compact data storage. Design of new quick and save .NET types with small overhead is not a simple task. This article describes creating of such type without overhead and with advantages only.
5 Apr 2015 by raypetriut
Helloi need to some information about ram such manufacturer name , part number , voltage and ... . i don't want to use WMI because itt cant get all data . the best way is SPD (Serial presence detect) table. CPUz is also use SPD to read ram information .so i want to know how can i access to...
11 Oct 2013 by ASP.NET Community
 ADO.NET stands for ActiveX Data Objects for .NET. It refers to the suite of data access technologies used to manipulate databases. ADO.NET is part
13 Dec 2022 by lock&_lock
I'm doing a Hackerrank challenge to compute the maximum and minimum sum of a set of 5 numbers. For example : Sample Input 1 2 3 4 5 Sample Output 10 14 Ouput 10 = minimum sum (exclude the biggest value), and 14 = maximum sum (exclude the...
7 Dec 2022 by Richard MacCutchan
while (array_size 6); The value of array_size cannot be less than zero, and greater than six, at the same time. It should be either one or the other, thus: while (array_size 6); // less than zero OR...
7 Dec 2022 by k5054
I'm with Richard, in that I see no reason for a SEGV at line 45. However, the problem statement says that the input is one line consisting of 5 integers. Your program, as presented here, seems to expect 2 lines, the first being the size of the...
13 Dec 2022 by JWleo
your cin has something wrong.first one ,you "cin" just work once but you want to read size times you gived.you should check your logical about your code. below is just some bad-code ,but can be running. void input() { int array_size = 0; ...
2 Nov 2018 by Member 14042074
Hello, I have to write 2 functions type of void which works on address of pointers. First function reserve memory for array of objects of class. Second function reserve memory for array of pointers to object of class. I don't know how it should work and how can I deliver and work on adress of...
2 Nov 2018 by Afzaal Ahmad Zeeshan
First thing, this is not C, this is C++ (you have a class in it!), secondly, since this is C++, why involve too much of a pointer stuff, when you can easily use other methods to do the same thing—why pointer-to-pointer-to-pointer? Maybe you are confusing the pointers-are-arrays statement a bit...
14 Apr 2016 by jurhas
Handle the dynamic allocated
22 Jan 2014 by Trey Wheeler
Using Java 1.6 on Android API 13 (3.2):We are working on a View Model framework. In this framework we can wait on another property to have a value before executing. In the following example we are awaiting the value from ModuleViewProperty before attempting to fetch a data count....
5 Jul 2016 by T. Herselman
2 years ago I went OCD on memcpy/memmove; and wrote over 140 variations (80,000 lines of code) of memmove; testing, disassembling, optimizing and benchmarking them on multiple machines. I never released the article or the code; until now! So I need to do it before I loose my mind!
28 Aug 2015 by Dmitriy Gakh
Development in C# without care of resource consumption can lead to overloading the system. This article describes a case with large waste of memory and CPU time and how to avoid it.
20 Jun 2012 by Aero72
Dear all,I'm pretty sure I know what the problem is....could I please ask for your time and consideration as to the optimum course of actionI have an application which gets data from a USB source and stores that data in a list. For convenience during development, I made it a public...
20 Jun 2012 by Sergey Alexandrovich Kryukov
A static collection is a typical source of a "memory leak by design". In .NET, you are more or less protected from the casual memory leaks, because you don't have to clean up memory after every operation you use it; the Garbage Collector (GB) takes care about it. Despite of the common believe,...
20 Jun 2012 by DaveyM69
What sort of data are you storing in your list? I have used (in testing) extremely large lists without issue.The size of any item in .NET is limited to 2GB. The maximum value for a lists capacity is 2147483647 so theoretically you could store that many bytes in the list and be right on the...
25 Sep 2013 by Savail
Hey,I know that I can simply load content of .exe in binary mode and I'll be able to get its binary representation but how about reading its binary representation from its process's memory? I've created a simple program which uses VirtualQueryEx and ReadProcessMemory to get the binary...
25 Sep 2013 by Sergey Alexandrovich Kryukov
Of course you cannot do such things in such a simple way. Even if you managed to copy the executable segment memory correctly. This is not how the memory is filled in when PE file is loaded. It's done via the system loader which actually makes a lot of work.The PE describes some chunks of...
19 Dec 2014 by OKarpov
How to use ASM in C#.NET and most fast memory copy method
29 Dec 2014 by MasterCodeon
Hello Everyone!i have created a little app that can emulate an electric piano(but it only will play sine waves) i have based my app on this articlenow i am using the play to stream part of the demo. what this does is it writes the entire wave file of what ever note i specify into memory and...
29 Dec 2014 by Sergey Alexandrovich Kryukov
Generally, there are at least two good ways to clean-up a memory stream without wasting much of the CPU and effort.First of all, if, at some moment, you have a stream and want to get a clear stream without any data, it means that you don't need this available stream instance at all....
29 Dec 2014 by Shaun Blain
I would suggest that if you are using the code from the article you referenced that the issue is in there. I browsed through the source code and there are several items that I would clean up. The first two being the binary reader and writer. These should be specifically disposed when the class...
2 Mar 2016 by QuantumDev
Hello,I have a problem with memory editing in C#.I need a way to find out the memory value of 'gta-sa' (0x2C0000) in C# as it changes every time the application starts.Image[^]Any help would be greatly appreciated :)What I have tried:I tried looking on Google but I dont think...
2 Mar 2016 by Dave Kreskowiak
Your going about it wrong. You open the process as if it was a file and start reading from the beginning of the process, an example of which you can find at Minesweeper, Behind the scenes[^].
2 Mar 2016 by QuantumDev
I have found a solution.Process proc = Process.GetProcessesByName("gta-sa").First();IntPtr startOffset = proc.MainModule.BaseAddress; IntPtr endOffset = IntPtr.Add(startOffset ,proc.MainModule.ModuleMemorySize); This will find the base address of the process I need.
23 Sep 2012 by BeStelios
Hi,I have an ItemsPanel extended with my IscrollInfoLogic, ContainerGenerator etc.. (Virtualizing)The ItemsPanel contains FrameworkElements which have a Property type of Drawing.If the Item is visible i do:On the Onrender if the DrawingProperty is not null i go with...
27 Jun 2017 by JSL721
In my case, I am studying to convert PDF to BMP and then convert BMP to PDF. I did consist of files which input and output. By the way, I would like to make memory streams instead of files but I would like to keep "a.pdf"(input file) and "a_bmp.pdf"(output file). I marked (#). I would like to...
29 Jun 2017 by Lockwood
Something like this? IO.FileStream fs = new IO.FileStream(myFile, IO.FileMode.Open, IO.FileAccess.Read); IO.MemoryStream ms = new IO.MemoryStream(); fs.CopyTo(ms);
9 Dec 2014 by Member 10364701
Hello everyone!I'm writing program to test memory leak. This is my code: public partial class Form1 : Form { Pen p = new Pen(Color.Red, 1.0f); Random d = new Random(); public Form1() { DoubleBuffered = true; ...
9 Dec 2014 by Assil
GDI has great examples of unmanaged resources which developers are responsible for disposing after using.In your example I see Pen and Graphic.The graphic you are not creating so you dont have to release it.The pen however, needs to be freed or released.Try to put it in the...
9 Dec 2014 by Sergey Alexandrovich Kryukov
In addition to Solution 1:You have two options:You can create your instance of Pen the way you do and dispose it in this Form.Dispose method: http://msdn.microsoft.com/en-us/library/aw58wzka%28v=vs.110%29.aspx[^].This is the approach designed to chain disposal in a set of UI elements...
9 Dec 2014 by Dave Kreskowiak
OK, everyone is focused on the Pen. That's not the problem in the code you posted.Well, there is one small problem where you're not disposing the Pen before your app terminates. This will lead to a handle leak and eventually break Window but you have to run this app over and over again,...
2 Mar 2016 by Umut Comlekcioglu
Imgur: The most awesome images on the Internet[^]With that image, Am I thinking wrong or is that true?What I have tried:When writing property, which way is more correct?
2 Mar 2016 by Dave Kreskowiak
Next time, just put the code in the post, not in an image.No, you're wrong about the "8 bytes".The top code snippet in the image is just a shortcut, an "auto-implemented" property. Behind the scenes it's doing exactly the same thing as the second code snippet in the image.In both...
16 Oct 2014 by EdisonMecaj
I'm not a pro in code writing and C# programming. I wrote a simple app to read from process memory using the ZeraPain script ReadProcessMemory(). Is working good with the 4 bytes and 8 bytes value. The other function of this App is that can read strings, but i really need to read Double values...
23 May 2018 by User 13204940
Hi, Just a quick memory management question, let's say I have the following: const std::vector intArray = {1, 2, 3}; delete intArray; This should allocate memory for the array then free it up again. How does this work in this situation? doSomething({1, 2, 3}); void doSomething(const...
23 May 2018 by Leo Chapiro
Have you tried to compile this code: const std::vector intArray = {1, 2, 3}; delete intArray; I think no, because you should get an error on "delete intArray" like "Expression must be a pointer". You can only delete the objects created on the heap with "new", not such stack objects...
23 May 2018 by Jochen Arndt
If you declare an object on the stack as in your case, it is destroyed automatically when going out of scope. As already noted at your other question, you should pass it by reference to avoid creating a copy. So it should be: { const std::vector arr = {1, 2, 3}; doSomething(arr);...
22 Mar 2020 by Mat 257
hello everyone. i have another mess. i am sure it depends on wrong momory garbage deleting. after having called funciton "Presentazione", when compiler reach marked line, it crash. it's surely memory probem. #include #include...
11 Mar 2020 by phil.o
string Visualizza[7][5]; The Visualizza variable is defined as a bidimensional array, with 7 elements in the first dimension and 5 elements in the second. This means that first dimension is indexed from 0 to 6, and second dimension is indexed...
12 Mar 2020 by Stefan_Lang
1. You can only delete objects that you created on the heap. Visualizza is an array declared on the stack, so you may not delete it. Trying to do so will always result in a crash. 2. You have allocated arrays of strings in your functions...
22 Mar 2020 by Mat 257
hi everyone; your suggestions solved my mess up. now i have another question, but is bit broad: suppose i want to set a strings array as a result of different row vector toghether; let s assume i want to gourp 3 strings vectors, 1) with 5...
22 Mar 2020 by CPallini
Note your Carta objects are constants. You don't need to dynamically allocate memory, neither explicitely nor implicitely. For instance: #include #include using namespace std; int main() { using namespace...
4 Jan 2017 by YznIT
HelloI want to take user input and make it the size of a dynamic array, and i did this as you can see in code below.the question is: I just wondring if this is right way to do it ? i have tested and even did a memory leak test but everything was just fine.Thank you :)What I...
4 Jan 2017 by Midi_Mick
Yep, looks good to me.The only thing you need to be aware of using this technique - if the Runner objects have a constructor that requires a parameter, this cannot be done. That's when you either need to use a std::vector or an array of pointers to type Runner instead, and then initialise (and...
17 May 2012 by sjsteve33171
Ive got some code that compares a file on the hard drive to the loaded memory copy and compares them. If it finds any differences i'm trying to overwrite the "Bad" memory with the original "Good" memory but it's crashing on me.It works because i can detect changes and it will log that there...
17 May 2012 by Aescleal
If all you're doing is reading a file, comparing it to some other version of it and then overwriting the differences why not just blat the correct one over the incorrect one after you've done the comparison?Your code seems well complicated for what you're trying to do. If you simplify your...
17 May 2012 by sjsteve33171
Sorry not quite. It's to avoid manipulation. For example.I run notepad.exe. I then run my app. My app then compares notepad.exe on the hard drive to notepad.exe in memory. If the notepad.exe in memory differs to the hard drive version it replaces the altered bytes with the correct...
13 Jun 2012 by Y0UR
Hey, I'm struggling against the following problem. I wrote a simple gaus algorithm, but AFTER it is done executing (succesfuly), pretty much any next attempt to alocate memory crashes the program and gives me the following error:"Windows has triggetred a breakpoint in ...This may be due to...
13 Jun 2012 by Albert Holguin
You're overriding the bounds of one of the dynamically allocated arrays, use your debugger to find out which one by simply stepping through your loops...or, you can look at the call stack to see which call triggered the error.Edit: I also see you're allocating memory and never deallocating...
13 Jun 2012 by Aescleal
You're doing pointer manipulation on pointers to dynamically allocated memory. This has a couple of effects: - you're orphaning blocks of memory - you couldn't free R1, even if you wanted to - as Albert said you're overrunning an array somewhere. You're not assigning xa anywhere for one...
4 Oct 2017 by MrJack Mcfreder
I am new to C++ and it is just a pain in the ass to find a single working example of reading process memory. What I have tried: After hours of googling, I eventually found a glimmer of hope for this code: // ConsoleApplication4.cpp : Defines the entry point for the console application. // ...
4 Oct 2017 by CPallini
Quote: I am new to C++ and it is just a pain in the ass to find a single working example of reading process memory. That's a hint your are trying to do something too difficult for your current knowledge. You should start reading the documentation: ReadProcessMemory function (Windows)[^],...
4 Oct 2017 by User 59241
I think CPallini's comment is apposite however there are many examples to be found by googling. This: How to use ReadProcessMemory in C++?[^] leads here: Stealing Program's Memory[^] which may give you a start.
5 Jan 2014 by Richard Tauber
Implementing dynamic polymorphism without virtual functions and sharing objects across process boundaries.
15 Mar 2021 by tugrulGtx
Header-only C++ tool that supports basic array-like usage pattern and uses multiple graphics cards in system as storage with LRU caching
5 Dec 2020 by Member 10563121
I have a problem that has stumped me involving memory mapping, and interchange between C++ (Visual Studio 2012 under Win7 32bit) and Python 2.7. In my C++ code I have a large (2Mbyte) image that updates at about 25Hz. I share this with another C++ .exe happily, using non-persistent (only...
3 Sep 2014 by bling
Try this:import mmapfpx = mmap.mmap (-1,-1,'IoAAOLICameraCameraFrame')
4 Sep 2014 by Member 10563121
Sadly this does not work. Using:fpx = mmap.mmap(-1,-1, 'IoAAOLICameraCameraFrame') is not allowed because the 2nd parameter gives the maximum length of the mapped file. Running it withfpx = mmap.mmap(-1,100, 'IoAAOLICameraCameraFrame')actually runs but if you print fpxyou get:...
5 Dec 2020 by Member 15013136
Uses Linux (not windows) This works using memory mapped files. I do not claim high speed or efficiency in any way. These are just to show an example of it working. $ python --version Python 3.7.9 $ g++ --version g++ (Ubuntu...
16 Nov 2015 by Laurie Stearn
Hi there,The aim is to prepare for an old fashioned Windows directory walk with view to RemoveDirectory aided by FindXXXXfile and SetCurrentDirectory.The variable array in question is called folderTreeArray keeps track of this.The first vector of the array represents the tree level,...
16 Nov 2015 by Sergey Alexandrovich Kryukov
It's possible that you just need to develop a more complicated data structure supporting semantic of an "array list". Say, you have too many elements to justify the use of a linked list with a separate element (with one or two pointers in each one), and the speed of addressing of an element is...
5 Feb 2014 by frostcox
Hey guys, I'm just wondering if you could help me and possibly give me some suggestions on how to achieve this. Ok, We have a file transfer solution which moves files from A to B and then to C. Files take a long time to transfer from A to B as there is over 300,000 files on the remote server so...
5 Feb 2014 by pdoxtader
It seems to me that what you really need is a faster way to get the list of files on the file system, rather then keeping 30 files or so in memory.In fact, a better solution given what you've written here is to keep the PATHS of those 30 critical files in memory, or in a log file - and have...
11 Oct 2013 by ASP.NET Community
CachingAuthor: Prakash Singh MehraIntroduction: It is a way to store the frequently used data into the server memory which can be retrieved very
17 Feb 2015 by PFalkowski
The way of calculating amount of memory occupied by some object in C#.NET
7 Jul 2017 by royal grandong
hi brother, How to clean variable from WinHttp api? I use codecave to call winhttp api but I want to hide the url. I have called RtlZeroMemory but the url is still visible... Can Variables be cleared with kernel32.RtlZeroMemory? Can kernel32.RtlZeroMemory be called from user mode? I have no...
6 Jul 2017 by KarstenK
You must only search, read and understand the in HttpOpenRequest documentation which says: "After the calling application finishes using the HINTERNET handle returned by WinHttpOpenRequest, it must be closed using the WinHttpCloseHandle function." WinHttpCloseHandle(hRequest); hRequest =...
2 Mar 2018 by istudent
I am using ItextSharp to generate pdf from Html tag. on document load, one of my function loop through and created Table tags for each section which is then passed via ajax to my MVC Controller. For test purpose when I hard code wrote the table tags and passed it did not throw any exception...
2 Mar 2018 by Gerry Schmitz
"DocWriter" is closing your stream. When other "usings" use preceeding "usings", they "may" close the underlying stream before you are finished with it. Rethink your "usings"; or put all disposals, in the proper order, in a "finally" block.
2 Mar 2018 by Gerry Schmitz
Did what? I simply said not to "dispose" of resources before you don't "need" them anymore. Your stream is getting close "prematurely"; which means you're "ending" a "using" before you should.
14 Feb 2014 by AdityaBohra
Hi, I am working on a project in which I have to read the size on 'Memory Dumps' and also remove these. I tried to get the path from registries but it giving error of "File not found" , in this thing I need your help. Is there any method to detect 'Memory Dumps' and remove those 'Memory...
14 Feb 2014 by Richard MacCutchan
See http://support.microsoft.com/kb/254649[^].
8 Oct 2015 by Jesús Álvarez
I plot several point in my chart ( 4 series x 1200points per serie), when i do that for 10 times (loop) my win form stop responding, only work the chart, progressbar stoip, timer elapsed time stop, buttons and panels stop, all GUI stop running.When a resize de form to smallest dimension, all...
18 Jun 2019 by Member 11882351
when i'm going to one page to another page that time showing my computer memory usage high. using ChromiumWebBrowser data with CefSharp and transfring 1 url page to other url page more then 20 time that time showing my computer memory high usage Image MemoryUsage.png - Google Drive[^] What I...
18 Jun 2019 by Gerry Schmitz
You're assuming it's even possible to "tune" browsers; and that one in particular. Since this browser is an IDisposable and I don't see any "using" code, it probably indicates you have a memory leak (by not disposing of resources properly).
18 Jun 2019 by Member 11882351
i'm browser in manny method so may be can't use using code in any one mehod.
7 Nov 2021 by Cinchoo
Use Cinchoo ETL to deserialize selective XML nodes from large XML file
12 Jan 2022 by Cinchoo
Tip to split large JSON file based on deeply nested array property using Cinchoo ETL
19 Aug 2012 by Swinkaran
I am developing a windows application using C# .Net. This is in fact a plug-in which is installed in to a DBMS. The purpose of this plug-in is to read all the records (a record is an object) in DBMS, matching the provided criteria and transfer them across to my local file system as XML files. My...
19 Aug 2012 by Sergey Alexandrovich Kryukov
CLI is a managed platform. It means that you don't directly allocate, but, more importantly, you do not control reclaiming memory. In terms of C#, you always allocate managed heap memory with "new" operators and never need to clean up the memory. It is done through the mechanism of Garbage...
19 Aug 2012 by Abhinav S
Understand the difference between managed and unmanaged code and don't worry too much about freeing up resources for managed code.Let the framework do this for you.
28 Feb 2014 by _Ravikant Tiwari_
This program will demonstrate the process of injecting code into already running processes. Here we have choosen to inject into Explorer
10 Apr 2017 by evilcode1
i still get this error when i try to debug the project i dont know why ... Quote: 'WindowsApplication13.vshost.exe' (CLR v4.0.30319: WindowsApplication13.vshost.exe): Loaded 'c:\users\evilcode1\documents\visual studio...
10 Apr 2017 by OriginalGriff
Your string is not a valid Base64 string: it's length is wrong at 37 bytes, and I don't believe in the least that a minimal Winforms app will come in at under 7.5K of binary, so I'd be looking for a Base64 string of around 10K. At a guess, you copy and pasted it badly - check your code that...
11 Nov 2020 by kohi11
Why is this code producing a "core dumped error"? It gives the right result, but indicates that a way I'm deallocating the allocated memory is wrong and I don't know why. What I have tried: #include #include ...
11 Nov 2020 by Greg Utas
It appears that you're putting integers into the array but then treating them as pointers in the first line of your destructor. I think you want niz=new Tip*[capacity]{}; // not Tip** EDIT: Now I notice that you're passing a pointer to each...
11 Nov 2020 by CPallini
Your code has several issues: Quote: for(int i=0;i niz2(niz); Quote: niz3=niz; Your class (badly) needs non-trivial...