How to know what memory zones are writable - memory

I want to know how to know what memory zones are flagged as writable while I am debugging a process.
So, I put a breackpoint in the code and I want to know in that moment what memory zone is writable. How can I do it? I'm using IDA Pro.
Thank you

It was easy:
View > Open Subview > Segments (or Shift+F7)

Related

How to use pin to find what area of memory is accessed

I am trying to use pin to find whether a program I run is accessing either stack or heap memory. How would I do this and what would I use for it?
Thank you!

Festo CPX-E Codesys - Can't set any persistent variables

I've been programming on our CPX-E-CEC-C1-PN but every time I just try to set one persistent variable it already says "out of memory".
Anyone ideas what setting/information I'm missing?
You can check the available/used memory of your device to be sure that the limit is already reached.
I already used Festo Codesys and I remember that the interface is pretty similar to the Codesys interface itself. So probably you will find the memory usage in the View -> View Memory Usage.
View Memory Usage image from Codesys 3.5
If the persistent memory is already reached the maximum of the controller, you will need to:
Change you approach to store the variables, changing the types in order to use less memory or, at least, use it in a mote intelligent way;
Change the controller model to another with more memory for the persistent variables;
Old question but i will reply for future visitors. You need to perform a clean all. this will redefine the memory and allow you to add more persistent variables.

How to use linux memory map on iOS?

I want to read some big files on iOS device, to make iOS device a better memory, someone told me maybe I can use linux memory map on iOS, but I have no idea of it. Or there are some other ways on iOS platform just like linux memory map? Thx so much.
On iOS, start with an instance of NSData and configure it to use memory mapping to map the contents of the file into memory.
As #rmaddy said, avoid premature optimizations. Assuming that "big files" means "larger than physical memory", then start with the above. If "big files" means "a few MB", then just read the files and be done with it until you quantify an actual performance issue.

Finding a Memory Bubble

This is either ridiculously simple, or too complex . . . .
In our application there is a form that loads some data from the database and displays it in the grid (putting it simply). When the data is refreshed the total memory usage climbs by about 50K (depending on how much data is displayed no doubt). Sounds like a memory leak, but when we shut down the application, FastMM is set with ReportMemoryLeakOnShutDown := True, and it doesn't report any abnormal memory leaks.
So it appears we have a memory bubble or bag. Something that is accumulating more memory each time it is run. Like a TList that keeps getting new items added to it, but the old ones never get removed. Then in the shutdown process all the items get destroyed. The rows displayed in the grid do not increase, but there are a lot of object lists behind the scenes that make this work, so it could be anywhere.
So my question is if anyone knows of a good trick for finding out what parts of an application are using how much memory . . . . I can think of lots of tedious ways of doing it (which I am in the process of doing - checking each list I can find), so I am hoping someone has a trick or technique I have not thought of.
Thanks in advance!
Update: Every refresh results in an additional 10-50K of memory being used. The users are reporting that eventually the application stops responding. It certainly acts like a memory leak, but FastMM (the memory manager) does not see anything leaking. I'll try some other memory tools . . .
Just F8 through the critical part and look at the process usage graph (Process Explorer from Mark Russinovich works great for that). When you find the culprit method, repeat the process but descend into that method.
Tools like AQTime can report difference in memory/object usage between snapshots. This might help you find out what keeps growing.
It looks like there is some memory allocated via custom AllocMem() calls, bypassing FastMM.
This can be midas. Andreas has a solution for this
Or some other InitXXX WinAPI call that allocates something, without freeing. Or some other third-party or windows dll used by project.
Does this happen every time you refresh the data or only the first time? If it's only the first time it could be that the system just reserves the memory for your application, despite the fact that it's not used at this time. (Maybe at some point the old and new data existed simultaneously in memory?)
There are many tools which provide you with informations about memory leaks, have you tried a different one?
Im not a FastMM expert, but I suppose that after a memory manager get memory, after you free the objects/components, it holds for future use with some zeroes or flag, I dont know, avoiding the need to ask the OS for more memory any time, like a cache.
How about you create the same form/open same data, N times in a row?
Will increase 50K each time?
Once I had the same problem. The application was certainly leaking, but I got no report on shutdown. The reason for this was that I had included sharemem in the uses-section of the project.
Have you tried the full FastMM-version? I have found that tweaking its settings gives me a more verbose information of memory usage.
As Lars Truijens mentioned, AQTime provides a live memory consumption graph, so in runtime, you can see what objects are using more memory whenever you refresh data.

first chance exception: system error 8: not enough storage space to perform the command

how do i debug something like this? i need the debugger to stop and show me where the problem is. don't just show it in the event log & then hang.
first chance exception: system error 8: not enough storage space to perform the command
i'm using delphi 2009. the problem doesn't happen regulary. i'm not eager to pepper my program with OutputDebugString calls to track this down!
thank you for your help!
You are looking at a resource leak on your server, more than likely... Either handle related, or memory related...
I've had this happen a lot, and it's always the case... There CAN be other causes, but I think a resource leak is your #1 cause...
You are going to have to either find it and fix it, or start putting debug checks in on all memory allocations, handle allocations, and log them anytime you can't get memory, or handles.
It's also possible that your CLIENT machine is out of resources, but usually, it's the server at fault...
Failing all that, give us some more idea of what you are doing, what the code looks like, etc, to help spot issues. Just based on the error alone, isn't a lot to go on...
If your program uses a lot of windows resources it could be a Resource Heap shortage.
There is a registry entry that can be increased to raise the heap size for XP. For Vista Microsoft already sets the default value higher. I recommend changing the default 3072 to at least 8192.
This information is documented in the Knowledge Base Article ID 126962 (or search for "Out of Memory"). Additional details concerning the parameter values may be found in the Knowledge Base Article ID 184802.
I suggest you read the knowledgebase article but the basic info on the change is:
1) Run Registry Editor (REGEDT32.EXE).
2) From the HKEY_ LOCAL_MACHINE subtree, go to the following folder:
\System\CurrentControlSet\Control\Session Manager\SubSystem
3) On the right hand side of the screen double-click on the key:
windows
4) On the pop-up window you will see a very long field selected. Move the cursor near the beginning of the string looking for this (values may vary):
SharedSection=1024,3072,512
5) SharedSection specifies the System and desktop heaps using the following format: SharedSection=xxxx,yyyy,zzz where xxxx defines the maximum size of the system-wide heap (in kilobytes), yyyy defines the size of the per desktop heap, and zzz defines the size of the desktop heap for a "noninteractive" window station.
6) Change ONLY the yyyy value to 8192 (or larger) and press OK.
7) Exit the Registry Editor and reboot the PC for the change to take effect.
Good Luck

Resources