LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-07-2003, 05:32 AM   #1
DHC
LQ Newbie
 
Registered: Mar 2003
Posts: 2

Rep: Reputation: 0
Unhappy User level memory fragmentation problem?


Hope someone can help with this. I've got a small program (happens to be java but the same code / jdk works fine on Solaris and windoze) that performs a lot of small mallocs. Actually my code doesn't, but putting in malloc hooks shows masses of em comming from the jre). If I run this program repeatedly eventually it'll SEGV in core_alloc ("below" malloc). (The program completes within a second and fails typically after a few hundred or thousand iterations.)

I've read a little about memory fragmentation and suspect this may be the cause. cat /proc/meminfo shows anything between 10 and 40 meg free at the time of the failure BTW...

The solutions I'm looking for therefore are:
- is memory fragmentation a likely cause of the problem?
- Presuming it is; performance isn't an issue - is there anything that can be run prior to the program on each iteration to get the system to "flush" it's pages (or whatever's required). The program is always run as root in normal operation (but also shows the same problem as a "regular" user).

Running SuSE (2.4.0-4GB kernel).

Many thanks in advance. I'm completely stuck on this so any help is very much appreciated.
 
Old 03-07-2003, 08:02 AM   #2
loke137
Member
 
Registered: Feb 2003
Location: Brasil
Distribution: Debian Etch
Posts: 147

Rep: Reputation: 15
I am a complete newbie to coding, so all I say might me BS. But I will still say it .
When you allocate memory, you should always free it at the end of the program right?
Also what are you iterating so much(well, not that much)? Could you give us the code so we can look at it and maybe search for a more eficient algorithm?
In college, I have done stupid recursive factorials programs with Pascal, they couldnt go past 15! . So if your algorithm is factorial, that might be the problem!
 
Old 03-07-2003, 09:00 AM   #3
DHC
LQ Newbie
 
Registered: Mar 2003
Posts: 2

Original Poster
Rep: Reputation: 0
Loke - thanks for the reply...

No - no need to free memory you've allocated in terms of "giving it back" to the system - any allocated heap memory (e.g. with malloc) is freed up when the program exits. At least in user space :O)

Having difficulty producing a small concise chunk of code that re-creates the problem as the particular code I'm using does or doesn't SEGV depending on the ordering of the .JAR files I add to the classpath. I believe that FindClass is causing a lot of memory fragmentation searching through the jars to find the class I want, so my question's more of a general one. If this is a memory fragmentation issue, a short program with lots of mallocs / frees should re-create it in theory.

BTW - the recursion you're talking about uses the stack.

Cheers.
 
Old 03-07-2003, 11:42 AM   #4
loke137
Member
 
Registered: Feb 2003
Location: Brasil
Distribution: Debian Etch
Posts: 147

Rep: Reputation: 15
Oh, I grasp the problem, but it is past my current knowledge, sorry
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
scanner under user level ohcarol Linux - Hardware 1 11-29-2005 03:58 PM
user level fork() is05 Linux - Newbie 1 07-29-2005 10:09 PM
code in user level ramu_ak Linux - Networking 0 08-21-2003 01:52 AM
Memory fragmentation problem? Idunno24 Programming 3 06-03-2003 12:33 PM
windoze user level shares theFuzzyOne Linux - Networking 0 04-16-2002 07:55 AM


All times are GMT -5. The time now is 03:51 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration