Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
101 user(s) are online (95 user(s) are browsing Forums)

Members: 1
Guests: 100

beworld, more...

Support us!

Headlines

 
  Register To Post  

Extended Memory (and just a memory) questions
Home away from home
Home away from home


See User information
Hi all !

Is there ppls who for real use Extended Memory ? As far as i aware its only broadblues with Sketchblock use it , so maybe question is mostly to him :)

So, i currently have some app, which have that kind of memory alloc/free functions:

#include <stdlib.h>
#include <string.h>

#include "main.h"

void *myzalloc_ (uint32_t size,
                 const 
char *what,
                 const 
char *file,
                 const 
char *func,
                 const 
uint32_t line)
{
    
void *ptr malloc(size);

    if (!
ptr) {
        DIE(
"No memory(%u), %s:%s():%u"sizefilefuncline);
    }

    
memset(ptr0size);

#ifdef ENABLE_PTRCHECK
    
ptrcheck_alloc(ptrwhatsizefilefuncline);
#endif

    
return (ptr);
}

void *mymalloc_ (uint32_t size,
                 const 
char *what,
                 const 
char *file,
                 const 
char *func,
                 const 
uint32_t line)
{
    
void *ptr malloc(size);

    if (!
ptr) {
        DIE(
"No memory, %s:%s():%u"filefuncline);
    }

#ifdef ENABLE_PTRCHECK
    
ptrcheck_alloc(ptrwhatsizefilefuncline);
#endif

    
return (ptr);
}

void *myrealloc_ (void *ptr,
                  
uint32_t size,
                  const 
char *what,
                  const 
char *file,
                  const 
char *func,
                  const 
uint32_t line)
{
#ifdef ENABLE_PTRCHECK
    
ptrcheck_free(ptrfilefuncline);
#endif

    
ptr realloc(ptrsize);
    if (!
ptr) {
        DIE(
"No memory, %s:%s():%u"filefuncline);
    }

#ifdef ENABLE_PTRCHECK
    
ptrcheck_alloc(ptrwhatsizefilefuncline);
#endif

    
return (ptr);
}

void myfree_ (void *ptr,
              const 
char *file,
              const 
char *func,
              const 
uint32_t line)
{
#ifdef ENABLE_PTRCHECK
    
ptrcheck_free(ptrfilefuncline);
#endif

    
free(ptr);
}

char *dupstr_ (const char *in,
               const 
char *what,
               const 
char *file,
               const 
char *func,
               const 
uint32_t line)
{
    if (!
in) {
        
ERR("no string to duplicate");
        return (
0);
    }

    
char *ptr strdup(in);
#ifdef ENABLE_PTRCHECK
    
uint32_t size = (typeof(size)) strlen(in);
#endif

    
if (!ptr) {
        DIE(
"No memory, %s:%s():%u"filefuncline);
    }

#ifdef ENABLE_PTRCHECK
    
ptrcheck_alloc(ptrwhatsizefilefuncline);
#endif

    
return (ptr);
}


The app in question, offten want to allocate 1.3gb , or 1.5gb, or 1gb. Which, in our limitation with 32bit and amigaos, when i have on running already eated about 250mb , leave us with less that 1.5gb.

I write some simple test case and found, that i can only allocate just about ~1.4gb on one malloc, while i have 250 mb free. So in summ its just 1.650 in whole , but its already barier to burn and crash. So its of course not 2gb (as 31 bit addressing), but even not 1.8gb, but ~1.7gb of memory which can be used under aos4 :)


So, question, can i use that Extended Memory thing, to just add relevant code in those helpers myalloc() and myfree() functions, so, they will just works as it, but just will have ability to alloc and 1.5gb via malloc, and 2gb and whatever extendent memory can handle.

At least for me will be enough to have ability to alloc 1.7gb at one push, so leave aos4 with 300 mb used, but currently limited to ~1.4gb.

Join us to improve dopus5!
AmigaOS4 on youtube
Go to top
Re: Extended Memory (and just a memory) questions
Quite a regular
Quite a regular


See User information
From what I understand you need to map extended memory into the lower 2GB address space, and then unmap it after you've done using it. If you have it mapped all the time, then there's no benefit to using it versus the normal memory allocation functions.

This is just like television, only you can see much further.
Go to top
Re: Extended Memory (and just a memory) questions
Home away from home
Home away from home


See User information
@kas1e

Quote:

I write some simple test case and found, that i can only allocate just about ~1.4gb on one malloc, while i have 250 mb free. So in summ its just 1.650 in whole , but its already barier to burn and crash. So its of course not 2gb (as 31 bit addressing), but even not 1.8gb, but ~1.7gb of memory which can be used under aos4 :)


Yes, this is subtlity sometimes missed. You have a limit of 2Gb of (signed) address space, system ram is not the only thing usuing that space, the first 256 of gfx card memeory, PCI card memeory etc also eat inot that so that is why a X1K sometimes appears to run out of memory evn when it has 500Mb "free" .

Quote:

So, question, can i use that Extended Memory thing, to just add relevant code in those helpers myalloc() and myfree() functions, so, they will just works as it, but just will have ability to alloc and 1.5gb via malloc, and 2gb and whatever extendent memory can handle.


No. To use Extended Memory in a useful way you need some kind of paging system.

For example sketchblock has buffer objects composed of a number of pages of Extended (or normal) memory. When these buffer are reference via their 'get or set methods' then the relavant pages are paged in and out using the extended memeory API functions. I have a LRU cache of paged in pages to optimise this process and limit the amount of memory space used at any one time whilst slaos reducing cache misses.

If your application needs to directly access very large blocks of memory in that way without any kind of access API (ie by simply dereferencing pointers,) you are not going to be able to use ExtMem for it.


Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project