[ 
https://issues.apache.org/jira/browse/TS-567?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

mohan_zl updated TS-567:
------------------------

    Attachment: clear_memory.patch

in build/aux/ltmain.sh, i wanna know whether or not should we support xfree 
like xmalloc
change 
#define XFREE(stale) do { \
  if (stale) { free ((void *) stale); stale = 0; } \
} while (0)
to 
#define XFREE(stale) do { \
  if (stale) { xfree ((void *) stale); stale = 0; } \
} while (0)
and add function xfree
void
xfree (void *mem)
{
  if (mem != NULL)
    free (p);
  else
    lt_fatal ("Freeing a NULL pointer");
}

considering WIN32 support, i did not remove the relevant codes in iocore/cache, 
but change the function, like:
CacheDisk::open
 #if defined(_WIN32)
-  header = (DiskHeader *) malloc(header_len);
+  header = (DiskHeader *) xmalloc(header_len);
 #else
-  header = (DiskHeader *) valloc(header_len);
+  header = (DiskHeader *) ink_memalign(sysconf(_SC_PAGESIZE), header_len);

in iocore/net/SSLNet.cc
void
SSLNetProcessor::initSSLLocks(void)
{

#if !defined (_IOCORE_WIN32)
  sslMutexArray = (ProxyMutex **) OPENSSL_malloc(CRYPTO_num_locks() * 
sizeof(ProxyMutex *));
#else
  sslMutexArray = (ProxyMutex **) Malloc(CRYPTO_num_locks() * sizeof(ProxyMutex 
*)); // this is not defined, and maybe we should remove it
#endif
  ...
}

> Cleanup of memory allocation in libinktomi++
> --------------------------------------------
>
>                 Key: TS-567
>                 URL: https://issues.apache.org/jira/browse/TS-567
>             Project: Traffic Server
>          Issue Type: Improvement
>          Components: Core
>            Reporter: Leif Hedstrom
>            Priority: Critical
>             Fix For: 3.1
>
>         Attachments: clear_memory.patch, malloc.txt
>
>
> There's a lot of ifdef's and debugging code paths around various allocation 
> schemes in libinktomi++. We should clean this up, and simplify. It'd also be 
> great to make it easy to enable various other allocators, e.g. jemalloc or 
> tcmalloc, as part of the build system, causing ink_malloc / xmalloc and STL 
> containers to use the new allocator. In particular for STL containers, it 
> means we might need to have some allocator setup / initialization?
> Also, when should we use ink_malloc() vs xmalloc() ? It's quite 
> inconsistently used right now I think. And, there are a few places using 
> malloc() (etc.) directly, which we ought to fix.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to