Ticket #328 (defect)
Opened 2 years ago
Last modified 2 years ago
os.freemem function
Status: closed (fixed)
| Reported by: | pspuser | Assigned to: | fraca7 |
|---|---|---|---|
| Priority: | major | Component: | PythonCore |
| Version: | current | Keywords: | |
| Cc: |
Hi! The os.freemem function dosen't returns the real psp free mem. I solved this with:
//==========================================================================
// Memory
#include <malloc.h>
int __freemem()
{
void *ptrs[480];
int mem, x, i;
for (x = 0; x < 480; x++)
{
void *ptr = malloc(51200);
if (!ptr) break;
ptrs[x] = ptr;
}
mem = x * 51200;
for (i = 0; i < x; i++)
free(ptrs[i]);
return mem;
}
static PyObject* PyPSP_freemem(PyObject *self,
PyObject *args)
{
SceSize mem;
if (!PyArg_ParseTuple(args, ""))
return NULL;
if (PyErr_CheckSignals())
return NULL;
mem = __freemem();
return Py_BuildValue("i", (int)mem);
}
Ciaooo Sakya
Change History
10/03/06 16:42:56: Modified by pspuser
- summary changed from os.freemem funciton to os.freemem function.
10/04/06 15:01:12: Modified by fraca7
- status changed from new to assigned.
10/04/06 15:07:13: Modified by pspuser
With Triple Triad PSP in the main menu I have more than 12mb free. I haven't my psp here, so I cannot check this now.
Ciaooo Sakya
01/27/07 11:35:19: Modified by fraca7
- status changed from assigned to closed.
- resolution set to fixed.
I implemented something like this as an os.realmem() function (documentation updated).

Mmmh, I'd rather find the function that returns the 'true' value. Your code works fine but it can be dangerous; if a native thread is running and tries to allocate some memory, it could fail though there actually is enough memory available...
BTW, how much free memory do you have at startup ?