allocating memory - Windows Mobile Development and Hacking General

I have realized that my use of malloc that has been working fine with sizes up to ~1.5mb always fails when going over that size. It has been rare that I ever actually need more than that but it creates a problem.
I am no expert on how windows sets up memory for programs and only have a rough idea about it. I have tried creating a heap and allocating memory from that, but that fails too.
eg
unsigned long sizeOfDataBlock;
HANDLE he=HeapCreate(NULL,sizeOfDataBlock+1024,NULL);
dose not return NULL
but
char*returnBlock=(char*)HeapAlloc(he,NULL,sizeOfDataBlock);
dose return NULL.
Can someone give some pointers on how to get hold of more memory to work with please.

You could consider using VirtualAlloc and VirtualFree instead I think. That's advisable for large allocations of contiguous memory.
V

I substituted them but it did not help. I also realized that the problem was not a size of 1.5mb but more like between 7-9mb. I was holding the same data in multiple seperate places so I re-aranged my code to use only 1 copy but the cost was more entangled code. The thing I still do not get is why the memory manager can show more than 20mb of free storage and 20mb free program memory but can't give me th 9 I want. On the first calls to malloc I can see the in use value rize by what I expected but before the last rize my error code tells me it failed.
Its probably bad practice to hog that much memory on a device any way.

I have found something else very interesting.
I made a small program to just allocate blocks and then give time to see the memory manager to confirm the effect. I can allocate as much memory in one call to malloc as the device can provide. Even if the program memory is less than what I request it adjusts with storage to allow huge allocations. I can still make it fail but only after about 24mb.
Why then can the same not be done from within my other program. Could it be that having more than one thread limits the amount of memory each thread can get. I would really like to understand this because memory allocations are at the hart of just about everything.
<<edit>>
I added 4 threads to my test app and tried again. The result was that I could allocate even more from the main thread, 4mb more. Why????

Related

Memory Loss Help

For some reason my xda 11 says i have 91.68 mb allocated for storage
yet the last time i looked at it there was only 28mb in use.
I have no pictures or sound files no extra programmes and have only 2.2 mb of data above 64K. I've closed down all my active programs and performed a soft reset yet nothing seems to help.
Any ideas??
I'm a bit confused about your terminology here - I read it as you have 98MB allocated, 28MB in use, and therefore 70MB free - does this correspond with what you're getting in the Settings-Memory applet?
I'm confused because I can't see a problem with the above - although it only leaves you with 29ishMB allocated for program execution it's a perfectly reasonable config. You can change allocation between storage and program by sliding the slider. You probably know all this, I've probably got the wrong end of the stick.
Looks like a bit has gone somewhere, I have 126.03 to begin with, you are out by a bit as yours only adds up to 119.68.
memory loss
ok sorry if i'm not explaining myself properly
i am currently looking my memory settings
which tells me i have 91.69 MB in use for storage leaving 10.19 free
and 18.06 MB in use for program and only 6.09 free
now what concerns me is that having been through file explorer i don't know what is taking up so much storage memory especially as i have no voice or picture files or have got any additional programs
firstly there is insufficent memory to run transcriber properly and secondly what happened to increase my storage use from 28mb to 91 when i hadn't even used it.
(i haven't even connected my xda to the net yet)
Any comments would be appreciated
cheers john
Hmm 90odd MB in use is indeed strange. Are you sure there are no large files anywhere? Have you installed anything recently? Have you made a recording and forgotten to stop it manually so that it filled the available memory (although you'd still find this as a large file). It's not normal for PPC apps to take up such amounts of storage, and without a directory listing or access to your device it's unfortunately going to be pretty much impossible to work out whats wrong.
Incidentally. storage vs program memory allocation can be automatically adjusted by the device itself if it needs to.
Check for camera files, or do a backup and do a hard reset back to factory settings, then look at it from there and check it as you install programs/files.
memory loss
Thanks for that guys I can't explain it either
i've got 02 data support looking in to it and they're stuck as well so they are escalating it ie sending it to someone else. I should hear back today or tomorrow.
i guess in the end i'll probably have to do a hard reset. I'm just worried that it might come back or i have a virus even though they don't exist on ppcs at the moment.
i want to get a 1gb storage card any tips ?
ps thanks again if you ever get arrested (not that you will) send me a private message and i'll look after you. (I'm in the old bailey tomorrow on a murder case)

What happened to the Memory Management Slider???

In WM2003SE there was a slider in the memory management that allowed us to allocated the ammount of memory we wanted for programs or storage.
Wheres it gone and is it possible to have it back??
No. Because WM5 doesn't use RAM as a storage area.
Thanks for the reply.
If I cant have the slider back is there any way of forcing WM5 to reduce the ammount of Storage it reserves, as I always have around 23Mb free which I just dont need.
if I could reduce this to 15MB this would free up 8Mb for my programs which then would make them fly instead I have to run SK-Tool Free up Ram application about 3 times aday to try and recover 2 or 3 Mb from the storage to give back to programs to help them run........especially the phone which is VERY tempermental when the program memory drops to around 15Mb, at this level I get alot of missed calls as the phone takes too long to respond.
There are two different types of memory in the Universal, one is flash (storage) and one is RAM (for executing applications), you can't change one into the other.
It's still there..just that MS overlayed a new panel onto the existing window and froze the controls. Just wait till the universal starts to hang, go into the Memory panel in Settings.. :evil:

Adjusting storage memory and program memory

Hi, is there a way to adjust the memory usage for the program, like adjust the storage and give it to program. Not like xda, the prophet does have a slider for the memory but could not be adjusted. Is there anyway how to go over this ?
Prophet, as well as many new WM5 devices have (physically) separate program and storage memories. And thus there is no built in way to adjust the amounts of the two.
The Prophet has a 64MB Ram and a 128MB Flash Size with a storage size of 42.55. Where did the 44.01 MB program came from? Is there a way to increase the MB size for the program? Because I believe that even though you can install several program using the storage, a portion of the program memory gets filled up until at the critical level, which will later play an important part once you start running a program which needs a higher memory. Any remedy to this?
The 64MB RAM is what I think should be called 'box figure'. It's what's printed on the box.
In reality you get 50+ actual RAM at leas 10 of which go to various OS functions and the rest is left for running programs to use.
Under WM5 non of it is used for files, but when you run programs, even built-in ones there are sometimes memory leaks which means that even though you closed the program some of the memory (sometimes more them 1MB) remains occupied.
The only known way to fully reclaim memory is to soft reset the device. I do it on my Jamin once a week when I am left with 12-10MB free.
Unfortunately, there is no way to add RAM to device.

Malloc/new never returns

I have a problem.
I make use of malloc or new in many places to store data in. I normally have no problem but there seems to be a limit on how much I can use it. I always free/delete as soon as I no longer need the memory and always check for 0 returned. I have mechanisms in place in case of 0 but when malloc actually fails it dose not return. Malloc just never returns and hence crashes my program. What could be the cause of this?
+The actual memory I am requesting is ~2-20k, the available memory is 20-30mb.
I am considering creating a heap, using it to allocate blocks from and destroying it to clean the memory. This is a time consuming change, dose anybody have some experience with this problem?
The annoying part is that the code works 100% on old devices and fails on new ones. I never thought i would be rewriting this code.
The heap way did work. The problem is that on ce, to create a heap you have to set aside the size first. Also there are still some problems I am having with memory that I pass out of a dll and then pass back in to free. Still its better than crashing! I may solve the freeing of individual pointers by just replacing it with a periodic call to HeapDestroy to clear them all out, something else that can't be done with malloc.

[Q] Seeking Basic Info - Optimus & P509

Hello -
This issue has been bugging me for a long time. I'm seeking some general information about the Optimus-T (LG P509) and Android design as a whole. My phone is not the latest and greatest and I've resisted rooting. Maybe this pushes me in that direction. But I need to come to a better understanding of what's going on and how things work in general. Hopefully one of you experts can give some advice.
Memory questions: I keep running low on memory in the device which provides for many goofy results when used. I've moved as many apps as possible to the 16gB SD card. The card has a lot of music on it with 3.2 gB remaining - plays great. Android Assistant reports the following memory compliment relevant to my question:
Memory Info(RAM) Used: 247.75mB
Free: 170.41mB
Total Memory: 418.53 mB​
Phone Space Info(ROM)
Used: 157.45mB
Free: 42.05mB
Total Space: 199.5mB​
Observations: As I watch the display, the RAM values shift slightly around depending on what the phone is doing at that moment. The values don't fluctuate too wildly at least not from what I observe. I get that part. But... when Phone Space(ROM) drops to the low 20mB level, the device slows to a crawl, often reboots, browser stops and drops back to the home page; all with no error notification. I clear the caches two-three times daily which will raise the ROM value but only by the amount of cache released. I found that keeping around 40mB in ROM provides smooth trouble-free operation. Here's the question: Why is ROM even involved in supporting program code/data operations like this? I've always assumed that ROM (Read Only Memory) by definition is static in nature and thus shouldn't change. Here in Android-land apparently things may not be the same as I understand. So I'm forced into uninstalling some really useful programs (ie Google+) that I like in order to bring the ROM value around the 40mB threshold. I know memory has a finite limit. I don't understand why ROM is even involved and thus why it "flexes". Can someone explain, please?
Look at the amount of available RAM above. Why doesn't the phone use this RAM for program code/data execution? Because I approach this from a Windows/PC background here, perhaps that's what's throwing me off. Still, it's got ample RAM that looks to be unused for the most part. Is there a command or setting (I've looked all over the place) to demand the phone use RAM over ROM? If it did that, I'd have plenty of space and no problem at all.
Given the above, if I stuck having to deal with low ROM, do any of you know if additional ROM/RAM can be added gaining more "Phone Space"? I'm not talking about the SD card; I'm talking about the base memory populated inside the device that serves as that valuable "Phone Space" referred to above?
I'd really appreciate a answer to this. Thank you for your time and any advice.
H
Hoibb said:
Hello -
This issue has been bugging me for a long time. I'm seeking some general information about the Optimus-T (LG P509) and Android design as a whole. My phone is not the latest and greatest and I've resisted rooting. Maybe this pushes me in that direction. But I need to come to a better understanding of what's going on and how things work in general. Hopefully one of you experts can give some advice.
Memory questions: I keep running low on memory in the device which provides for many goofy results when used. I've moved as many apps as possible to the 16gB SD card. The card has a lot of music on it with 3.2 gB remaining - plays great. Android Assistant reports the following memory compliment relevant to my question:
Memory Info(RAM) Used: 247.75mB
Free: 170.41mB
Total Memory: 418.53 mB​
Phone Space Info(ROM)
Used: 157.45mB
Free: 42.05mB
Total Space: 199.5mB​
Observations: As I watch the display, the RAM values shift slightly around depending on what the phone is doing at that moment. The values don't fluctuate too wildly at least not from what I observe. I get that part. But... when Phone Space(ROM) drops to the low 20mB level, the device slows to a crawl, often reboots, browser stops and drops back to the home page; all with no error notification. I clear the caches two-three times daily which will raise the ROM value but only by the amount of cache released. I found that keeping around 40mB in ROM provides smooth trouble-free operation. Here's the question: Why is ROM even involved in supporting program code/data operations like this? I've always assumed that ROM (Read Only Memory) by definition is static in nature and thus shouldn't change. Here in Android-land apparently things may not be the same as I understand. So I'm forced into uninstalling some really useful programs (ie Google+) that I like in order to bring the ROM value around the 40mB threshold. I know memory has a finite limit. I don't understand why ROM is even involved and thus why it "flexes". Can someone explain, please?
Look at the amount of available RAM above. Why doesn't the phone use this RAM for program code/data execution? Because I approach this from a Windows/PC background here, perhaps that's what's throwing me off. Still, it's got ample RAM that looks to be unused for the most part. Is there a command or setting (I've looked all over the place) to demand the phone use RAM over ROM? If it did that, I'd have plenty of space and no problem at all.
Given the above, if I stuck having to deal with low ROM, do any of you know if additional ROM/RAM can be added gaining more "Phone Space"? I'm not talking about the SD card; I'm talking about the base memory populated inside the device that serves as that valuable "Phone Space" referred to above?
I'd really appreciate a answer to this. Thank you for your time and any advice.
H
Click to expand...
Click to collapse
In answer to your question, I'd like to say that it's just one of those things you'll have to go with(Let me assure you I hate it as much as you do)
Android phones need at least 30~40 MB free space in internal memory to function smoothly...maybe that's just the way they are programmed. That's the reason why phones today come with much higher internal memory...and no, there's no way to make the ram to be used instead or to increase the internal memory. In short-you'll just have to install less apps...or if you root your phone you can try App2SD scripts
Sent from my LG P500 using XDA Premium
Press thanks button if I helped you
Thank you.
So again, I have to change my thinking about how "ROM" here is designed and implemented. ROM (in a PC for example) is certainly used but not in the same way with the same characteristics as used in Android-ville.
And so this tells me, rooting is the last hope for gaining back critical internal (ROM) space so I can have more apps. Again, right now in stock mode, App2SD reports that no further apps can be moved to the card.
I do like this device a lot. It's small, compact and feature rich for what I need. There's lots of good advice on here about the rooting process. It's just "scary" territory as I enter this not knowing if I can avoid the brick.
Thanks again.
H
Hoibb said:
Thank you.
So again, I have to change my thinking about how "ROM" here is designed and implemented. ROM (in a PC for example) is certainly used but not in the same way with the same characteristics as used in Android-ville.
And so this tells me, rooting is the last hope for gaining back critical internal (ROM) space so I can have more apps. Again, right now in stock mode, App2SD reports that no further apps can be moved to the card.
I do like this device a lot. It's small, compact and feature rich for what I need. There's lots of good advice on here about the rooting process. It's just "scary" territory as I enter this not knowing if I can avoid the brick.
Thanks again.
H
Click to expand...
Click to collapse
Rooting your device is actually the easy part, it's possible but unlikely that you will brick it, I had the same thoughts when I done my O1 P500, but now I'm rooted I wouldn't ever go back... I used superoneclick & that had the option to Unroot, I am not sure on other applications because I haven't used them. Basically follow the instructions right down to the letter (re-read or do it when you're wide awake so you don't miss anything), but in my own personal experience rooting it was easy.
Once rooted download the app called "Root Checker Basic" from android market, it should come back saying "This device has root access".
Once rooted you can do so much more, run apps that require root, backup your entire android system, and alot more.
Hope my info helped you, but in all honesty rooting is up to you, don't let anyone else make that choice for you, but just as a side note, rooting will void your warranty then again it's reversible.
Everything written here is based on my own experience and is only intended as a guide.
Hoibb said:
Hello -
This issue has been bugging me for a long time. I'm seeking some general information about the Optimus-T (LG P509) and Android design as a whole. My phone is not the latest and greatest and I've resisted rooting. Maybe this pushes me in that direction. But I need to come to a better understanding of what's going on and how things work in general. Hopefully one of you experts can give some advice.
Memory questions: I keep running low on memory in the device which provides for many goofy results when used. I've moved as many apps as possible to the 16gB SD card. The card has a lot of music on it with 3.2 gB remaining - plays great. Android Assistant reports the following memory compliment relevant to my question:
Memory Info(RAM) Used: 247.75mB
Free: 170.41mB
Total Memory: 418.53 mB​
Phone Space Info(ROM)
Used: 157.45mB
Free: 42.05mB
Total Space: 199.5mB​
Observations: As I watch the display, the RAM values shift slightly around depending on what the phone is doing at that moment. The values don't fluctuate too wildly at least not from what I observe. I get that part. But... when Phone Space(ROM) drops to the low 20mB level, the device slows to a crawl, often reboots, browser stops and drops back to the home page; all with no error notification. I clear the caches two-three times daily which will raise the ROM value but only by the amount of cache released. I found that keeping around 40mB in ROM provides smooth trouble-free operation. Here's the question: Why is ROM even involved in supporting program code/data operations like this? I've always assumed that ROM (Read Only Memory) by definition is static in nature and thus shouldn't change. Here in Android-land apparently things may not be the same as I understand. So I'm forced into uninstalling some really useful programs (ie Google+) that I like in order to bring the ROM value around the 40mB threshold. I know memory has a finite limit. I don't understand why ROM is even involved and thus why it "flexes". Can someone explain, please?
Look at the amount of available RAM above. Why doesn't the phone use this RAM for program code/data execution? Because I approach this from a Windows/PC background here, perhaps that's what's throwing me off. Still, it's got ample RAM that looks to be unused for the most part. Is there a command or setting (I've looked all over the place) to demand the phone use RAM over ROM? If it did that, I'd have plenty of space and no problem at all.
Given the above, if I stuck having to deal with low ROM, do any of you know if additional ROM/RAM can be added gaining more "Phone Space"? I'm not talking about the SD card; I'm talking about the base memory populated inside the device that serves as that valuable "Phone Space" referred to above?
I'd really appreciate a answer to this. Thank you for your time and any advice.
H
Click to expand...
Click to collapse
GET ADB ON YOUR COMPUTER( GOOGLE IT)
TYPE
ADB SHELL
SetInstallLocation 2
U WILL BEABLE TO MOVE MOST APPS TO SD WITHOUT ROOTING
From the instructions I've googled, it's not clear - do I move them using the phone or do I move them via the computer?
H

Categories

Resources